Here is the important part of code, it’s inside a FixedUpdate if that matters:
float moveHorizontal = joystick.Horizontal (); float moveVertical = joystick.Vertical (); Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical); //Rotate direction vector with the camera Vector3 rotatedDir = camTransform.TransformDirection(movement); rotatedDir = new Vector3 (rotatedDir.x, 0, rotatedDir.z); rotatedDir = rotatedDir.normalized * movement; rb.AddForce (rotatedDir * velocity);
The problem is in the line ‘‘rotatedDir = rotatedDir.normalized * movement;’’
‘+’ and ‘-’ do work but ‘*’ (which is what I need) and ‘/’ don’t. That part of my code is to rotate the direction of the vector with the camera(as said in the comment). Anyone know what I’m doing wrong? And why does it speficy the same operand twice in the error?