0
I am a beginner in Unity 5, I am trying to create a game 2d, where I want to put diagonal movements after collisions, currently get my object after collision to be thrown up, but I can not in any way make a diagonal movement, my matrix has a scale axis y(0,6)e(0,-6) x(6,0) and (-6,0), I am working with 2 objects a rectangle and a circle, the circle is inside the rectangle, when the circle hits the walls of the rectangle happens the collision and action. If anyone can help me, be grateful.
I have no code for diagonal, only for the jump up.
Code: using Unityengine; using System.Collections;
public class Player : Monobehaviour { public Vector2 jump = new Vector2(0,300); Private Rigidbody2d Rb; private Transform tmf;
// Use this for initialization
void Start ()
{
rb = GetComponent<Rigidbody2D>();
// tmf = GetComponent<Transform>();
}
// Update is called once per frame
void Update ()
{
clik();
}
//Dectando colisão de objetos e adicionando ação.
void OnCollisionEnter2D(Collision2D coll)
{
if (coll.gameObject.tag == "piso")
{
jump.y += 100;
rb.velocity = Vector2.zero;
rb.AddForce(jump);
}
}
//Destruir objeto ao clickar
void clik()
{
if (Input.GetMouseButtonDown(1))
{
Destroy(tmf);
}
}
}
Sorry there, I did not pay attention to the date of posting.
– Celso Formiga