- Home /
MMORPG Rotate Character
hi all,i need help....im making mmorpg game and i don't know how to make something....When i press A or D my character going to left,what i need to do to make my character (with camera) rotate when i press A or D...
Example: Press A - My character and camera rotate in left
sorry for bad english
Have you thought through that? it might be a bit akward. I guess that in your camera controller Script you need to swap the mousex with the horizontal keys, first to look how it behaves.
"Have I thought through that?" is a great question to ask yourself. I don't know how many times I've tried to rush to a conclusion and realizing I need to think through what I really want.
Answer by vincent dupuis morneau · Oct 22, 2010 at 04:10 PM
well i dont know if you aready got a script for moving your character so i made you one :P
here is the script:
var speed = 3.0;
var rotateSpeed = 3.0;
function Update ()
{
var controller : CharacterController = GetComponent(CharacterController);
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed = speed * Input.GetAxis ("Vertical");
controller.SimpleMove(forward * curSpeed);
}
@script RequireComponent(CharacterController)
so now you have a character thats moving so now for the camera, in unity there is aready a script that does what you need.in your project panel search for smoothfollow.When you got it add it to your camera then you only need to click on your camera and look in the inspector for your smoothfollow script.once you found it there is a target, drag your character from the hierarchy to the target. start the game and the camera will follow the movement of your character :D
Your answer
Follow this Question
Related Questions
character and Camera rotate 2 Answers
Rotate camera to character angle 0 Answers
Turning torso of character with mouse 0 Answers
Clamping the Camera, according to the player ? 1 Answer
How can I align Axis? 0 Answers