How to repel a ball ... Need math help, calling all gurus!
Hi Guys. Im struggling to get my head round around a problem and wonder if any of you lovely people can help?
I have a ball shot across the screen to where the player selects. The ball is always launched at the same speed. The ball has a change velocity at 400. What i want it to do is when it goes close to another actor it gets repelled away at its relevant angle, but also the closer the ball is to the actor the greater the repelled force is. So, if you fire within say 100 of the repel actor, it gets repelled just a little, if you shot at say 30 away from the actor then it takes a greater effect.
I can achieve the distances using magnitude, thats fine, i just really dont know what to do about the repel behaviour!
Cheers
I have a ball shot across the screen to where the player selects. The ball is always launched at the same speed. The ball has a change velocity at 400. What i want it to do is when it goes close to another actor it gets repelled away at its relevant angle, but also the closer the ball is to the actor the greater the repelled force is. So, if you fire within say 100 of the repel actor, it gets repelled just a little, if you shot at say 30 away from the actor then it takes a greater effect.
I can achieve the distances using magnitude, thats fine, i just really dont know what to do about the repel behaviour!
Cheers
Comments
email me if I don't get back to you soon. tenrdrmer(at)yahoo.com
Cheers
Cheers
Constrain game.distancefromball to magnitude(game.ballX-self.positionX,game.ballY-self.positionY)
constrain game.angle to ball to VectorToAngle(game.ballX-self.positionX,game.ballY-self.positionY)
now you will always have the angle between the two and the distance between the two.
Just add an accelerate to the ball and use the magnitude data as part of an equation (have a number divided by game.distancefromball) and use game.angle for the angle relative to scene.
Tenrdrmer has sent me a demo which was very kind of him and also thanks to Sci Tunes who was minutes behind posting a solution.
Man i love this community