playMaker

Author Topic: Force character controller to move? (Dash mechanic) [Solved]  (Read 2371 times)

Vindetta

  • Playmaker Newbie
  • *
  • Posts: 2
    • View Profile
Force character controller to move? (Dash mechanic) [Solved]
« on: March 20, 2015, 10:48:51 PM »
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
« Last Edit: March 24, 2015, 07:48:57 PM by Vindetta »

cgmonkey

  • Playmaker Newbie
  • *
  • Posts: 15
    • View Profile
Re: Force character controller to move? (Dash mechanic)
« Reply #1 on: March 21, 2015, 05: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?

Vindetta

  • Playmaker Newbie
  • *
  • Posts: 2
    • View Profile
Re: Force character controller to move? (Dash mechanic)
« Reply #2 on: March 24, 2015, 07: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.

MABManZ

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 126
    • View Profile
    • MABManZ.com
Re: Force character controller to move? (Dash mechanic) [Solved]
« Reply #3 on: March 25, 2015, 02:26:54 AM »
There is a "Get Direction" action that is used for exactly this

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