- Home /
My Bullets aren't moving...
So I'm firing bullets by finding the angle between the player and the mouse position and then transform.Translate the x and y axis towards it. The bullets however just sit there and do not move. Here is my code:
var bulletMoveSpeed: int = 15;
function Update () {
var xdir: float = PlayerScript.hitPoint.x - PlayerScript.pPosx;
var ydir: float = PlayerScript.hitPoint.y - PlayerScript.pPosy;
var angle: float = Mathf.Atan2(xdir,ydir);
var lx = Mathf.Cos(angle);
var ly = Mathf.Sin(angle);
transform.Translate.x(bulletMoveSpeed * lx * Time.deltaTime);
transform.Translate.y(bulletMoveSpeed * ly * Time.deltaTime);
}
So my question is, how do I move my bullets instead of them just sitting there?
Answered that on your other question's comments. Translate.x is incorrect.
Answer by tahcet · May 16, 2012 at 04:12 PM
Scripting is not exacly one of my forces but try adding a rigidbody or some kind of physics for the projectiles. I hope that was of any help :)
Turns out the Translate.x was wrong. Thanks though for giving your time to give your opinion, I do appreciate.
Your answer
Follow this Question
Related Questions
Trouble with aiming with the mouse in a 2D sidescroller 0 Answers
Bullets follow mouse after shooting in Sidescroller 1 Answer
Sidescroller Bullets Follow Mouse After Being Shot 2 Answers
Aiming with the mouse in a 2d shooter, and then shooting to the mouse 2 Answers
Mouse Dragging/Throwing Objects with the Mouse Like in Black & White (The Game) 1 Answer