- Home /
Freeze x,y position according to object's axis
Hi,
I have been working on this problem for a few days now. I have a syringe-object and would like to, on button press, lock the movement of the syringe so that it only moves forwards and backwards according to the syringe's tip.
I have tried "freeze position contstraints," but that locks the axis to the global axis. I have also tried "transform.position = Vector3 (transform.position.x, 0, 0)", but this also moves the object according to world axis.
Is there a way to do this? Would you like more information about what I am trying to do?
Thank you, David
Are you moving this object according to physics, or are you manipulating the transform?
I am controlling the syringe with the mouse and would only like to move the syringe forwards and backwards, ignoring the other axis' of the object. So, both I suppose
I'm a bit confused. The answer depends on how you are attempting to move the object. Can you post your movement code?
Answer by Seizure · Jul 30, 2013 at 04:37 PM
Depending on where the front of your object is you can do:
syringe.transform.Translate(Vector3.forward * speed);//Where speed should be something from 0 - 1 anything more it goes to fast
Your answer
Follow this Question
Related Questions
Change position of camera on scene load? 1 Answer
Create a straight gradient equation with a grid of 3d objects 1 Answer
Following another object's position/rotation like parent/child relationship? 4 Answers
How do you set the initial value of a variable to an objects current position in unity? 1 Answer
Create an animation with variables? 1 Answer