Wednesday, December 9, 2015

unity - I have a problem rotating a 2D game object after collision


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

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...