- Home /
Jumping Towards Orientation of the character
Hello, I am making a 2d game in wich the character falls on a slope and rotates while falling with a fixed rotation. When touching the ground the character jumps at an angle relative to the slope. I want it to always jump towards the orientation of itself, meaning towards his head, no matter what orientation it has at the moment when is touching ground with its legs. I atached a picture to make myself more understandable and my code so far. I am new to unity and i hope you can help me with this problem. Thank you very much!
private void FixedUpdate() {
IsTouchingGround = Physics2D.OverlapCircle(groundCheckPoint.position, groundCheckRadius, GroundLayer);
if (IsTouchingGround)
{
rigidBody.velocity = new Vector2(rigidBody.velocity.x, JumpPower);}
void Update() { GetComponent().angularVelocity = Spin; if (Input.GetKey(KeyCode.Space)) { GetComponent().angularVelocity = CtrSpin; } //GetComponent().AddForce(new Vector2(0,JumpPower), ForceMode2D.Impulse); } }
Your answer
Follow this Question
Related Questions
Hi, knife hit, how do you control the speed of the wheel and the speed of the knife? 1 Answer
How to make ragdoll arms point towards mouse? 1 Answer
How could I emulate a cherry picker arm's rotation? 0 Answers
Unity 2D movement and rotate sprite to the direction it is moving in 1 Answer
Unity2D rotate object with limits 0 Answers