Question by
SwitchingBrains · Aug 15, 2016 at 03:36 PM ·
rigidbody2dvelocityanglecalculation
Calculate velocity x and y directions based on speed and angle
Well, it might be a simple math solution but i can't seem to find it. It's pretty straight forward.
I have a player object that 'jumps' by adding y-velocity like this :
_rigidBody2D.velocity = new Vector2(_rigidBody2D.velocity.x,jumpHeight);
I want to use this same method to let the player bounce from another object. That object can be rotated. So i get something like this:
player.Bounce( bounceForce, transform.rotation.eulerAngles.z );
public function Bounce( bounceForce : float, bounceAngle : float )
{
bounceForceX = calculate the force by the ueler angle and force;
bounceForceY = calculate the force by the ueler angle and force;
_rigidBody2D.velocity = new Vector2(bounceForceX,bounceForceY);
}
Thanks in advance!
Comment
Your answer
Follow this Question
Related Questions
Why angle between these two velocities is 45? 2 Answers
why is the rigidbody's velocity zero in OnCollisionEnter2D? 1 Answer
Player randomly stops moving 1 Answer
[Not solved] RigidBody2D sticks to walls 0 Answers
rigidbody.velocity.x doesn't work :( 2 Answers