- Home /
FPSInput??
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...
It is usually a bad idea to break traditional controls. You should only do this if you do not use the mouse to turn.
Answer by aldonaletto · Aug 27, 2011 at 12:58 AM
The 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); }
Answer by Waz · Aug 25, 2011 at 03:06 PM
Yes, like nearly everything, it is possible. Have a go at modifying the script yourself. If you have difficulty, we're here to help.
I tried to modify (FPSInputController and Character$$anonymous$$otor ), but its sooooooooooo difficult .
please any 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.
Your answer
Follow this Question
Related Questions
Where is the FPSPlayer Script? 0 Answers
Help with fps script 2 Answers
RigidBody FPS Walker Collision Glitch 1 Answer
Mobile Controller and Game Controller 0 Answers
Compiler Error...Help Needed. 0 Answers