Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Vindetta on March 21, 2015, 01:48:51 AM

Title: Force character controller to move? (Dash mechanic) [Solved]
Post by: Vindetta on March 21, 2015, 01:48:51 AM
Hi guys, I'm trying to make a player character do a quick dash in the direction they are facing.  So far it works as long as I am giving the input to the controller but I would like it to work if they are standing still.

I am using a Character Controller (no rigidbody), with "Get Axis Vector" storing a vector 'movement' and using "Controller Simple Move".  When I call the Dash state I simply use the "Controller Simple Move" again with a high speed and "Wait" for 0.3 seconds.  The problem is the 'movement' vector I am sending is Zero if the character is standing still.

My question, is there a way to find the direction the character is facing and change a Vector to be a value of 1 in that direction?

Also, I tried just plugging in a Vector variable like (0,0,1) and it just makes them run along the global Z axis and faces them in that direction.  I have been looking all over the forums and going through the tutorials but I haven't had any luck.

Thanks for any help
Title: Re: Force character controller to move? (Dash mechanic)
Post by: cgmonkey on March 21, 2015, 08:12:00 AM
There probably a better way but couldn't you set a bool value, 0 for left, 1 for right, then do a bool compare?
Title: Re: Force character controller to move? (Dash mechanic)
Post by: Vindetta on March 24, 2015, 10:48:42 PM
Ok, I got it working.  There might be an easier way but here it is for anyone that wants to know.

I use "Get Rotation" to store the player 'Y Angle' into a float.  Then I created a custom action that generates a vector using Quaternion.AngleAxis() and stores the values into float variables.  Then use "Set Vector3 XYZ" to set the vector I use to dash.

I could probably just store the vector created from the AngleAxis line but I couldn't get the values to be saved right (x is y, z is x, y is z).  Here is the code I used.

var vForce = Quaternion.AngleAxis(playerRotation, Vector3.forward) * Vector3.right;

dashX.Value = vForce.y;
dashZ.Value = vForce.x;

Hope this helps anyone looking for a similar issue.
Title: Re: Force character controller to move? (Dash mechanic) [Solved]
Post by: MABManZ on March 25, 2015, 05:26:54 AM
There is a "Get Direction" action that is used for exactly this

http://hutonggames.com/playmakerforum/index.php?topic=41.0