How to set jump angle from rotating collider ( surface )?
Hey, Making a game about jumping ball to rotating colliders and climbing as far as u can in that way, but have a problem with jumping angle from these rotating colliders. I want to jump from these col at 90 degree and dont know how to set it ( because location of surface where my main is pinned is still changing - dont know how to set perpendicular jump ). Here is my code so far:
private bool isPinned = false;
public float jump = 100f;
public float speed = 30f;
public Rigidbody2D rb;
void Update()
{
if (!isPinned)
rb.MovePosition(rb.position + Vector2.up * speed * Time.deltaTime);
}
void OnTriggerEnter2D(Collider2D col)
{
if (col.tag == "Rotator")
{
transform.SetParent(col.transform);
isPinned = true;
}
}
private void FixedUpdate()
{
if (Input.GetButtonDown("Jump") || Input.GetMouseButtonDown(0))
{
isPinned = false;
rb.MovePosition(rb.position + Vector2.up * jump * Time.deltaTime);
}
}
}
For sure problem is in last void, because I can Jump but only a few 'spaces' and only 'up' from coll - whatever it means. Also I dont know why during the jump my 'main' is still rotating as last collider... Looking for any HELP! Thank You in advance.
If your character is rotating with the platform then it should be as easy as changing occurrences of Vector2.up
to transform.up
(you should assign transform to a variable on start as I think it calls GetComponent each time which can be slow)
Your answer
![](https://koobas.hobune.stream/wayback/20220612155051im_/https://answers.unity.com/themes/thub/images/avi.jpg)