- Home /
Question by
pianoguy04 · Feb 05, 2014 at 03:47 AM ·
tagsif
Make rolling ball player spin script
Nothing happens when I hit it. I am new to unity so I don't very much. function OnCollisionEnter (collision : Collision) {I'm trying to make my ball/Player spin around when I hit a enemy object.
if(gameObject.tag == "Enemy") { transform.Rotate(Vector3(0, 3000, 0) * Time.deltaTime);
}
}
Comment
Best Answer
Answer by NickP_2 · Feb 05, 2014 at 06:07 AM
using the transform straight away is physics unfriendly because it will ignore all the colliders or gravity.
I'd sugest you to attach a rigidbody to the object, and add a torque force to it.(more info here)
So whenever you need An object to behave natural with the laws of physics, add a rigidbody To it. For more info about rigidbodys look here
Good luck !
Your answer
![](https://koobas.hobune.stream/wayback/20220613132557im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Is it possible to create a new Tag by script ? 1 Answer
My backpack script doubt 0 Answers
How to get around adding loads of "if" commands in my script 2 Answers
Multiple function conditions? 1 Answer
How to finish my else if statement? 2 Answers