I want to move an object with a certain angle and speed, is there a was to set this as an initial velocity so that it is still possible for the object to collide and bounce of other objects using its rigid body?
1 Answer
Figured it out, here is the code that i made:
float angle, speed;
Vector2 newVelocity;
//use sin and cos to work out x and y speed
velocity.x = Mathf.Cos(angle) / speed;
velocity.y = Mathf.Sin(angle) / speed;
//apply the new velocity to the current object
this.GetComponent<Rigidbody2D>().velocity = newVelocity;