- Home /
Quick question on transform.Translate(); C#
So this is a tiny bit embarrassing, can someone tell me why I can't do this?
void Update () {
Vector3 myVector = new Vector3 (Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
transform.Translate(myVector) * speed;
transform.TransformDirection (myVector);
}
I get the error: 'Only assignment, call, increment, decrement, and new object expressions can be used as a statement.'
Comment
Answer by S_Darkwell · Mar 15, 2015 at 07:38 PM
" * speed " needs to be inside of trans.Translate();. It should read:
transform.Translate(myVector * speed);
Otherwise, you are multiplying transform.Translate the action, not the value of myVector.
Your answer
Follow this Question
Related Questions
stop object(door) translation 0 Answers
C# Smoothing Out transform.Translate 4 Answers
Help with casting a raycast C# 1 Answer
Loop code just stops 2 Answers
Distribute terrain in zones 3 Answers