- Home /
Move character's position to middle of object
Hello, here's the code I have right now to make the character move to the center of an object. It only works if the object follows the global z axis though.
if(onObject)
{
transform.position.z = Mathf.Lerp(transform.position.z, railPosition.z, Time.time * 3.0);
}
Here's a diagram so you can see what I'm talking about:
diagram_help.jpg
(114.2 kB)
Comment
Answer by ScroodgeM · Aug 21, 2012 at 09:28 PM
if(onObject) { transform.position = Vector3.Lerp(transform.position, railPosition, Time.time * 3.0); }
Your answer
Follow this Question
Related Questions
how do i lock the mouse at center and lock it 1 Answer
Locking the mouse cursor without it centering after unlocking it? 0 Answers
Find open position 1 Answer
Moving along a local axis with a slider.. 0 Answers
Turning character slowly with Slerp 1 Answer