Oh, this sounds like a fun project! I will tell you the basics, but beyond that, figure it out yourself, for it will be a fun process.
First you are going to need physics for this. Uh, something like F=MA and V=D/T or something like that. Then you just set the distance to the paddle, and then check collision at the point. If the paddle is, let's say, within 1 unit of the ball in the x direction, send it back the other way! Do the same with the net. If the ball doesn't hit the paddle, start a timer for say .5 seconds, and then delete the ball and create a new one.
Cool. Unfortunately this is all jibberish to me. I'm not sure how to handle the triggering. I really could use someone to help me on figuring how to script all this.
I'm not asking for someone to do the work for me. But for someone to guide me threw it. I'm unfortunatly still learning all of this and I can't make heads or tails of this.
Yes actualy I'm trying to follow this tutorial ATM. Not having much luck. I'm not sure how to implement these physics in the game. I want to make it so that both player need to be ready before the round starts. For this I figured Space would be the triggering key. Then its a matter of Spawning the ball and pushing it in either direction to start the round. I'm very confused threw all of this and I could really use a partner or someone to work on the map with me. I fear I am still too new for this project...
These things should get you started. You should be able to find information about everything by making use of the search bar on this site. If not, I would be happy to expand... just not all at once :P
Well if this is trivial, please someone show me. lol I'm lost. I've been trying to understand the function setting in triggers. The tutorial is clear but I can't seam to get it to work properly. I'm starting to doubt my ability to make maps :(. I really want to do this.
The first thing that comes to mind for me with bouncing is: If your field is vertical (moving from one paddle to the next results in a change in y direction), just negate the y velocity when it collides with a paddle. When it collides with a left or right wall, just negate the x velocity.
For moving the projectile, have a trigger with a loop that has a wait of 0.0 seconds, and have the action in the loop be to move the projectile ahead by the velocity you store. You could store the velocity in a variable, or as the custom value for the projectile unit.
Does this help?
I'm still curious as to whether it's possible to cause a unit to bounce in data. Or to at least use a trigger to bounce a unit that is being moved by a mover, not via the trigger.
Well it helps. I understand the concept behind it. But I'm missing the knowledge to put it in practice. I'm trying to figure out how to change the angle when the ball reaches the wall at a certain angle. Trying to calculate which angle I should give it when it bounces off.
Okay. I created a bunch of variable. I don't know if I'm on the right track but none of the tutorials seam to help me.
I created a variable to store the angle of the ball. I'm guessing I can make a mathematical equation with it when the ball bounces off the balls. I'm still not too sure on how to approche this. I also created a trigger which requires both player to press space bar. This starts the game. A voice count down is activated and once that ends there's a little explosion at the center of the map and the ball spawns. Now. I'm trying to make it so that when the ball spawns it spins on itself and shoots in a random direction. Any thoughts on how I may achieve this?
The angle of the ball does not matter. Only its position and cartesian velocity.
Look at this:
l <-
The arrow is pointing in the negative x direction. When it strikes the wall, it should directly bounce back. It will then be pointing in the positive x direction.
This is true no matter what the y velocity is when striking a vertical wall. Just keep a variable "x velocity" and "y velocity". Use "move unit instantly" to "point with offset". Have the point be the unit's current location, and the offset be the x and y velocity.
"Bounce of the balls". Is that a typo, or do you want the ball to bounce off multiple balls as well as the walls? If so, I've done it before, and could try to help you, but it is a bit more complicated, and probably really annoying to do with triggers without inline operators.
Ok. I think I understand a little bit what you mean. No there is only 1 ball.
But lets say the ball touches the right side of the pheonix. How do I make it go towards the right a little more and if it hits the left to go towards the left.
if the ball hits the top wall with a 75 degree angle how calculate the bouce degree angle thingy.
Hitting the wall does not matter which angle. If you hit a wall like this:
_
The x velocity will not change. When an object strikes another object, the object pushes back on the striking object perpendicular to itself.
Try dropping a ball on the ground straight down. Notice it will bounce right back up directly. Now try dropping a ball on the ground, but with a slight forward speed. Notice how it still bounces up the same way. As well, notice how after hitting the ground, although it's bouncing upwards now, the forward speed and direction have not changed at all.
As for hitting the right side of the pheonix, try this:
Get two balls. Place one still on a table. Roll another ball of the same size directly head on with the still ball. Notice how the still ball begins moving at the same speed and direction as the original rolling ball. As well, you will observe that the previously rolling ball comes to a complete stop.
Now, roll the ball into a rectangular box, and hold the box still. It will bounce off the box the same as a wall.
Now, roll the ball again into the box, but move the box slowly towards the ball as the ball is rolling. It will again bounce off the same way, but the ball will move faster in the new direction. The momentum of the box is transferred to the ball when it collides. Since you are holding the box, it's unlikely its momentum will change, so you can just add the speed of the box directly to the ball's new speed.
Vexal may do this a bit differently than me (and would probably explain it differently,) but for my propulsion/physics systems I have a loop constantly propel the "ball" toward it's own position offset by it's facing angle - always moving it forward, essentially. I suppose you could use a variable or something instead to store the angle, but I've found it to be rather convenient to simply make the ball face another direction when I want it to turn, especially because setting the time for the Make Unit Face Angle function to anything above 0 will cause the ball to curve toward the target angle. So when the ball collides with an object or wall, I use a bit of arithmetic to determine the target angle and use the Make Unit Face Angle function to change the direction. The bit of arithmetic to determine the target angle is probably the most difficult part of this method.
I would write a guide, but I'm not sure what I have to say for it to be understandable. I know this stuff because I've taken 2 years of physics courses and read many books on this subject.
If you could ask specific questions instead of say you don't know how to do it, I might be able to help more.
Do you need help with understanding the physics, or do you need help applying them to the editor?
Also, don't misunderstand what Vexal is saying. If a ball bounces, you do need the angle that it impacts, you just don't need to CHANGE the angle. Not sure if you got that or not, but I figured it was worth mentioning.
You are going to need to implement gravity also, obviously. If you want, you can implement some other forces, like wind resistance if you want to. If I can remember correctly, once you get gravity working correctly, adding in another force isn't too difficult. (Although I don't know if it would be necessary for a game like ping pong)
Hello there. I've been working on a Ping Pong map. I finally got the Movement Working for the two pads.
My concept is a 3d environment but with a 2d Game style.
I'm trying to figure out how to make the ball move from left to right in the screen while bouncing off the sides and off the player pads.
I have to admit, I'm at a loss on how to even begin this triggering. Any insight?
@DarlD: Go
Oh, this sounds like a fun project! I will tell you the basics, but beyond that, figure it out yourself, for it will be a fun process.
First you are going to need physics for this. Uh, something like F=MA and V=D/T or something like that. Then you just set the distance to the paddle, and then check collision at the point. If the paddle is, let's say, within 1 unit of the ball in the x direction, send it back the other way! Do the same with the net. If the ball doesn't hit the paddle, start a timer for say .5 seconds, and then delete the ball and create a new one.
Great to be back and part of the community again!
@TacoManStan: Go
Cool. Unfortunately this is all jibberish to me. I'm not sure how to handle the triggering. I really could use someone to help me on figuring how to script all this.
I'm not asking for someone to do the work for me. But for someone to guide me threw it. I'm unfortunatly still learning all of this and I can't make heads or tails of this.
@DarlD: Go
Have you already checked out this tutorial?
http://www.sc2mapster.com/forums/resources/tutorials/22121-triggers-implementing-a-physics-engine/
It should help clarify the process of setting up physics for a ball.
@Chiquihuite: Go
Yes actualy I'm trying to follow this tutorial ATM. Not having much luck. I'm not sure how to implement these physics in the game. I want to make it so that both player need to be ready before the round starts. For this I figured Space would be the triggering key. Then its a matter of Spawning the ball and pushing it in either direction to start the round. I'm very confused threw all of this and I could really use a partner or someone to work on the map with me. I fear I am still too new for this project...
Things which you may find useful to learn about in this endeavor:
These things should get you started. You should be able to find information about everything by making use of the search bar on this site. If not, I would be happy to expand... just not all at once :P
@BasharTeg: Go
Thank you. I will look into this.
And yeah sure. Every bit of help is much appreciated. I'll upload the map and any pointers you could give me on how to approche this particular map.
Triggering this is fairly trivial.
I'm curious, however - Is it at all possible to implement bouncing using data?
@Vexal: Go
Well if this is trivial, please someone show me. lol I'm lost. I've been trying to understand the function setting in triggers. The tutorial is clear but I can't seam to get it to work properly. I'm starting to doubt my ability to make maps :(. I really want to do this.
@DarlD: Go
The first thing that comes to mind for me with bouncing is: If your field is vertical (moving from one paddle to the next results in a change in y direction), just negate the y velocity when it collides with a paddle. When it collides with a left or right wall, just negate the x velocity.
For moving the projectile, have a trigger with a loop that has a wait of 0.0 seconds, and have the action in the loop be to move the projectile ahead by the velocity you store. You could store the velocity in a variable, or as the custom value for the projectile unit.
Does this help?
I'm still curious as to whether it's possible to cause a unit to bounce in data. Or to at least use a trigger to bounce a unit that is being moved by a mover, not via the trigger.
@Vexal: Go
Well it helps. I understand the concept behind it. But I'm missing the knowledge to put it in practice. I'm trying to figure out how to change the angle when the ball reaches the wall at a certain angle. Trying to calculate which angle I should give it when it bounces off.
Okay. I created a bunch of variable. I don't know if I'm on the right track but none of the tutorials seam to help me.
I created a variable to store the angle of the ball. I'm guessing I can make a mathematical equation with it when the ball bounces off the balls. I'm still not too sure on how to approche this. I also created a trigger which requires both player to press space bar. This starts the game. A voice count down is activated and once that ends there's a little explosion at the center of the map and the ball spawns. Now. I'm trying to make it so that when the ball spawns it spins on itself and shoots in a random direction. Any thoughts on how I may achieve this?
@DarlD: Go
The angle of the ball does not matter. Only its position and cartesian velocity.
Look at this:
l <-
The arrow is pointing in the negative x direction. When it strikes the wall, it should directly bounce back. It will then be pointing in the positive x direction.
This is true no matter what the y velocity is when striking a vertical wall. Just keep a variable "x velocity" and "y velocity". Use "move unit instantly" to "point with offset". Have the point be the unit's current location, and the offset be the x and y velocity.
"Bounce of the balls". Is that a typo, or do you want the ball to bounce off multiple balls as well as the walls? If so, I've done it before, and could try to help you, but it is a bit more complicated, and probably really annoying to do with triggers without inline operators.
@Vexal: Go
Ok. I think I understand a little bit what you mean. No there is only 1 ball.
But lets say the ball touches the right side of the pheonix. How do I make it go towards the right a little more and if it hits the left to go towards the left.
if the ball hits the top wall with a 75 degree angle how calculate the bouce degree angle thingy.
@DarlD: Go
Hitting the wall does not matter which angle. If you hit a wall like this:
_
The x velocity will not change. When an object strikes another object, the object pushes back on the striking object perpendicular to itself.
Try dropping a ball on the ground straight down. Notice it will bounce right back up directly. Now try dropping a ball on the ground, but with a slight forward speed. Notice how it still bounces up the same way. As well, notice how after hitting the ground, although it's bouncing upwards now, the forward speed and direction have not changed at all.
As for hitting the right side of the pheonix, try this:
Get two balls. Place one still on a table. Roll another ball of the same size directly head on with the still ball. Notice how the still ball begins moving at the same speed and direction as the original rolling ball. As well, you will observe that the previously rolling ball comes to a complete stop.
Now, roll the ball into a rectangular box, and hold the box still. It will bounce off the box the same as a wall.
Now, roll the ball again into the box, but move the box slowly towards the ball as the ball is rolling. It will again bounce off the same way, but the ball will move faster in the new direction. The momentum of the box is transferred to the ball when it collides. Since you are holding the box, it's unlikely its momentum will change, so you can just add the speed of the box directly to the ball's new speed.
@Vexal: Go
I understand the concept. But I'm still un-able to put it in motion. I could really use a guide.
Vexal may do this a bit differently than me (and would probably explain it differently,) but for my propulsion/physics systems I have a loop constantly propel the "ball" toward it's own position offset by it's facing angle - always moving it forward, essentially. I suppose you could use a variable or something instead to store the angle, but I've found it to be rather convenient to simply make the ball face another direction when I want it to turn, especially because setting the time for the Make Unit Face Angle function to anything above 0 will cause the ball to curve toward the target angle. So when the ball collides with an object or wall, I use a bit of arithmetic to determine the target angle and use the Make Unit Face Angle function to change the direction. The bit of arithmetic to determine the target angle is probably the most difficult part of this method.
I would write a guide, but I'm not sure what I have to say for it to be understandable. I know this stuff because I've taken 2 years of physics courses and read many books on this subject.
If you could ask specific questions instead of say you don't know how to do it, I might be able to help more.
Here is what I think needs to be answered.
Do you need help with understanding the physics, or do you need help applying them to the editor?
Also, don't misunderstand what Vexal is saying. If a ball bounces, you do need the angle that it impacts, you just don't need to CHANGE the angle. Not sure if you got that or not, but I figured it was worth mentioning.
You are going to need to implement gravity also, obviously. If you want, you can implement some other forces, like wind resistance if you want to. If I can remember correctly, once you get gravity working correctly, adding in another force isn't too difficult. (Although I don't know if it would be necessary for a game like ping pong)
Great to be back and part of the community again!
@TacoManStan: Go
You only need the angle if you're using polar coordinates. I find x,y coordinates to be much simpler.
I don't think pong has gravity nor wind resistance.