Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: taforyou on July 07, 2012, 06:31:05 PM
-
I'm just trying to understand the concept of CharacterController move and try to convert C# >> Playmaker Methode flow ... anyone can show me how to setup state and transition for this script ???
Thank you
var speed : float = 6.0;
var jumpSpeed : float = 8.0;
var gravity : float = 20.0;
private var moveDirection : Vector3 = Vector3.zero;
function Update() {
var controller : CharacterController = GetComponent(CharacterController);
if (controller.isGrounded) {
// We are grounded, so recalculate
// move direction directly from axes
moveDirection = Vector3(Input.GetAxis("Horizontal"), 0,
Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
if (Input.GetButton ("Jump")) {
moveDirection.y = jumpSpeed;
}
}
// Apply gravity
moveDirection.y -= gravity * Time.deltaTime;
// Move the controller
controller.Move(moveDirection * Time.deltaTime);
}
-
Hi,
have you investigate the action "Controller simple move"? you first need to get the user input with the action "Get axis Vector" and pass the "store vector" to the "controller simple move" "move vector" field.
Bye,
Jean
-
Thank you Jean .. i already investigate the action "Controller simple move" and also "Controller move" maybe i'm confuse with concept of Get Axis and Get Axis vector. i can get the object to move but the problem is about object that has character controller
can i implied "Get Axis" is use for control object that has rigidbody and Get Axis vector is use for control Object that has Character Controller ?
Thank you
-
Hi
nop, the two are completely unrelated.
you can use getAxis and getVectorAxis to do anything you want with it, it is not tight to controlling character at all. you could control your own controller for flying a plane, moving the camera, anything.
1: create a vector 3 fsm variable name "movement"
2: On a state, first have a "get Axis Vector" action and plug "movement" in the field "store vector"
3: on the same state right after "get Axis Vector" have the "Controller simple move" and plug "movement" to the field "move vector"
that is sufficient to control the character now.
BUT, you don't need a rigidBody attached to the character controller, this is not supposed to work that way. the characterController is a kind of a rigidBody already.
Bye,
Jean
-
Thank you so much :)