- Home /
Question by
Gloop · Jun 24, 2013 at 06:08 PM ·
objectorientationconstraint
How to get an object to point in a certain direction?
Fairly simple I would assume. What I need is a way to keep an object up-right.
I want the top of the object to be pointing up, but not locked there. I would like to have the object simply TRY to stay upright. So that the player can knock the object around, but the object always returns to facing upright.
Any help is greatly appreciated!
Comment
Answer by robertbu · Jun 26, 2013 at 03:48 AM
Here is a simple script that may solve your problem.
#pragma strict
var qTo : Quaternion;
var speed = 10.0;
function Start() {
qTo = Quaternion.Euler(Vector3.up);
}
function Update() {
transform.rotation = Quaternion.Slerp(transform.rotation, qTo, Time.deltaTime * speed);
}
Your answer
Follow this Question
Related Questions
Making a ball move towards the mouse? 1 Answer
Change Object's Origin 1 Answer
Position in front of an object? 2 Answers
How do I increase speed after collision? 2 Answers