- Home /
How to rotate game object on fixed position
Hi can anybody please tell me that how to make game object rotate on fixed position! Please
tell me the full procedure with steps as i'm beginner to unity.
Answer by aldonaletto · Oct 12, 2012 at 09:37 PM
You should use transform.Rotate - this rotates the object without modifying its position. If you want the object to spin continuously around the Y world axis, for instance (script attached to the rotating object):
var rotSpeed: float = 60; // degrees per second
function Update(){
transform.Rotate(0, rotSpeed * Time.deltaTime, 0, Space.World);
}
O$$anonymous$$G! It's really working! Thanks a lot......
Dear Aldo, Can you tell me how to add animation to my coin while player collect it (something similar to Temple run).
I suspect that Temple Run uses a simple particle effect: the coin is destroyed and a single particle is instantiated to replace it and do the animation. Using the old ParticleEmitter, this could be done in the OnTriggerEnter event in the coin script:
var effect: ParticleEmitter;
function OnTriggerEnter(other: Collider){
if (other.tag == "Player"){
// create effect at coin position and with player rotation
Instantiate(effect, transform.position, other.transform.rotation);
Destroy(gameObject); // coin suicides
}
}
You should create the particle effect so that it emits a single particle to the left and with a down velocity that will make it fall, and use the coin image. If you don't know how to do this, post a new question - this subject is too complex to be handled in comments!
Your answer
Follow this Question
Related Questions
Detect a gameObject's tag via OnCollisionEnter() 5 Answers
Help with string to gameObject.name 2 Answers
Trying to make the enemy fire 1 Answer
[C#] Raycasts and Object Tags 1 Answer