Greeting,
I have recently been working on a game that applies the first person view concept, and I was coding in my character movement, and I know this is a noob question, but I’m stuck, I got my character to move but when rotating the mouse, the character does not go in the indicated direction. I was using a character controller at first to fix this issue, but the Character controller wasn’t ideal with my other assets. I hope this was clear enough, please help.
//Mouse Movement
//X direction
rotLR = Input.GetAxisRaw("Mouse X") * mouseSense;
transform.Rotate (0f, rotLR, 0f);
//Y Direction
vertRot -= Input.GetAxisRaw("Mouse Y") * mouseSense;
vertRot = Mathf.Clamp (vertRot, -yTopRange, yBottomRange);
cam.transform.localRotation = Quaternion.Euler (vertRot, 0f, 0f);
if (isWalking) {
// Set the movement vector based on the axis input.
movemt.Set (h, 0f, v);
// Normalise the movement vector and make it proportional to the speed per second.
movemt = movemt.normalized * tempSpeed * Time.deltaTime;
// Move the player to it's current position plus the movement.
rigidBody.MovePosition (transform.position + movemt);
//Using with CC don't want
/*Vector3 speed = new Vector3 (h, vertVel, v);
speed = transform.rotation * speed;
cc.Move (speed * Time.deltaTime);*/
}
You can simply get a vector pointing in the characters direction by using transform.forward nd then you can multiple the horizontal input with this one. Same with sideways vector, but with transform.right. If you add these two together, you get the movenent vector
You’ll have to dig through the preferences menu in MD - you’re looking for “formatting” somewhere. You can both have it automatically create the kind of brackets you want, or just turn off the automatic indentation altogether.
Also your view on where brackets go are heretical.