I'm developing a simple flip game where a cube flips and the bar a it collides with should start rotating after collision. Most snips involve destroying an object, but that's not my case.
Here is my code:
using UnityEngine;
public class CheckI : MonoBehaviour
{
float x;
public Rigidbody2D rb2d;
void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.tag == "bar")
{
x += Time.deltaTime * -10;
transform.rotation = Quaternion.Euler(0, 0, x);
}
}
}
How do I start rotation after collision?
No comments:
Post a Comment