- Home /
move script problem
here is my script i want my car to move towards the mouse so i have a mouse look script for that. I want it to move towards the mouse so i made a new script called mouse move, here's what i have:
function Update () { if (Input.GetMouseButtonDown(0)) new Vector3(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"), 0); }
Please edit your post and format your code with the 1010 button, to make it more readable. Secondly, what is wrong with your script? What part of it doesn't work? What have you tried/haven't tried?
Take a look at other "mouse look" questions on the site. Once you've oriented your game object correctly, you can use @GBStudios' suggestion below.
I edited the script for you - follow @$$anonymous$$eltdown suggestion whenever you post some question here (select the code and click the 101010 button to format it). That's all you have in your script? It does nothing! (I suspect it doesn't even compile). It just creates a Vector3 with x and y set to $$anonymous$$ouse X and $$anonymous$$ouse Y values. This vector should be assigned to some variable, and this variable should be used to control the movement. What's your car? A rigidbody or a CharacterController? Or just a model?
Answer by AVividLight · Aug 02, 2011 at 05:50 PM
Hey Conflictbliz,
I am not quite sure what your problem is, but if you just want it to move forward when you push 0, I can help...
It will be something like this:
In C#:
if(Input.GetKey("0"))
transform.Translate(Vector3.forward * Time.deltaTime * 1);
In JavaScript:
if(Input.GetKey("0")) {
transform.Translate(Vector3.forward * Time.deltaTime * 1);
}
I hope you can get it working!
-Gibson
thanks i copied the fpswalker script and added that ins$$anonymous$$d of the delta time it had and now i have it always moving towards my mouse without a character controller but it wont stop and shouldn't it be if (Input.Get$$anonymous$$ouseButton(0)
sorry guys the 10101 button is not working correctly could it be chrome and thanks to Gibson i edited his script a little bit and i got it to work so when i click the car moves when i unclick the car stops thanks alot really help because now i can move the car without a character controller giving it physics.
Your answer
