- Home /
Question by
SebastianRSP · Apr 14, 2014 at 10:32 AM ·
c#2drotationrigidbody2dvelocity
Unity C# 2D Adding Velocity on rotation
Hey there, I am trying to add velocity to a 2D object, in 45 degrees to the right, I am aware that I can type: transform.right or transform.up to get different directions, but what if I want to add force, 45 degrees to the right? This is my current script: if(Input.GetButton("Fire1")){ clicked = false; goat.rigidbody2D.velocity = transform.right meterLevel 2; }
Thank you for your time :D
Comment
Best Answer
Answer by grahnzz · Apr 14, 2014 at 12:49 PM
If u want to move in the direction in between right and up:
goat.rigidbody2D.velocity = (transform.right + transform.up) * meterLevel * 2;
Your answer
Follow this Question
Related Questions
2D Geometry dash-like ship physics 0 Answers
Movement Relative to Rotated Parent 1 Answer
Flip over an object (smooth transition) 3 Answers
Projetil rotation in straight line trajectory 2 Answers
Pysics not working as expected 1 Answer