hi …
I’m using FPS Input controller.
when I Press Left button the player walk side to the left , I want to let the player turn (rotate) to the left instead of walk side .
is that possible ???
thanks…
hi …
I’m using FPS Input controller.
when I Press Left button the player walk side to the left , I want to let the player turn (rotate) to the left instead of walk side .
is that possible ???
thanks…
Yes, like nearly everything, it is possible. Have a go at modifying the script yourself. If you have difficulty, we’re here to help.
You have to try to learn someday. If not, then you have to make do with the scripts as they are. The way to learn is to try. Read and understand the scripts as they are, then change them to your needs.
– WazThe First Person Controller script CharacterMotor.js is very complicated, and you will get nothing but headaches if you try to modify it.
You can start with the example script given in CharacterController.Move. It’s very simple and can be easily modified.
The script below is just a version of this example that I’ve modified to turn left and right. Read the Move example and compare to this script to learn what was modified. Try to modify the example script to do both things: turn left/right, and strafe when you press Shift, for example.
Attach this script to the First Person Controller, and disable its original scripts CharacterMotor and MouseLook in the Inspector. There’s a second MouseLook attached to the camera, but it only controls the camera movement.
var speed : float = 6.0;
var jumpSpeed : float = 8.0;
var turnSpeed : float = 60;
var gravity : float = 20.0;
private var moveDirection : Vector3 = Vector3.zero;
function Update() {
var controller : CharacterController = GetComponent(CharacterController);
var turn: float = Input.GetAxis("Horizontal");
transform.Rotate(0, turn * turnSpeed * Time.deltaTime, 0);
if (controller.isGrounded) { // only move or jump if grounded
moveDirection = transform.forward * Input.GetAxis("Vertical") * speed;
if (Input.GetButton ("Jump")) {
moveDirection.y = jumpSpeed;
}
}
// Apply gravity
moveDirection.y -= gravity * Time.deltaTime;
// Move the controller
controller.Move(moveDirection * Time.deltaTime);
}
It is usually a bad idea to break traditional controls. You should only do this if you do not use the mouse to turn.
– WazWhile that's true for <i><i>generic formatting</i></i>, it doesn't apply equally to a large-block code-formatted section, which is denoted by four spaces prior to each line of text, with an empty line before it. normal post text [empty line] _ _ _ _ code here normal post text
– Eno-Khaon