playMaker

Author Topic: 3rd Person Character Movement  (Read 33474 times)

Cybershead

  • Playmaker Newbie
  • *
  • Posts: 7
3rd Person Character Movement
« on: March 11, 2012, 07:13:53 AM »
Hi,

Dose anyone know how to in playmaker or know if a script that can give you great movement and key structure like
Jump
Run
Walk
Kill ,etc

This is something that is not widely avalible on the web, i started to make my own and used a great Wow camera script, but not knowing the script very well at all i have come unstuck.
I brought Playmaker for this reason but the simple 3rd person is not good at all for what i want.
It would be great if someone could tell me of a source to use or buy etc, i was using the script below to move my character and i used a different script to animate. I hope someone can help.

Cybershead

#pragma strict

var walkSpeed = 8.0;
var runSpeed = 10.0;
var jumpSpeed = 10.0;
var gravity = 20.0;
var rotateSpeed = 3.0;


private var grounded : boolean = false;
private var moveDirection = Vector3.zero;

function FixedUpdate() {

var controller : CharacterController = GetComponent(CharacterController);

transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);


var forward = transform.TransformDirection(Vector3.forward);

var curSpeed = walkSpeed * Input.GetAxis ("Vertical");




if(Input.GetKey(KeyCode.LeftShift) && Input.GetAxis("Vertical")) {

controller.SimpleMove(forward * runSpeed);

}




controller.SimpleMove(forward * curSpeed);


if (grounded) {

if (Input.GetButton ("Jump")) {

moveDirection.y = jumpSpeed;

}

}



moveDirection.y -= gravity * Time.deltaTime;


var flags = controller.Move(moveDirection * Time.deltaTime);

grounded = (flags & CollisionFlags.CollidedBelow) != 0;

}




@script RequireComponent(CharacterController)




« Last Edit: March 11, 2012, 07:15:28 AM by Cybershead »
If the path of life was made for us, why do we try so hard to change it?

justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 280
Re: 3rd Person Character Movement
« Reply #1 on: March 12, 2012, 02:35:54 PM »
have you watched the 3rd person controller playmaker video?

http://www.screencast.com/users/HutongGames/folders/PlayMaker/media/e73a91a6-8b33-4e6a-8e4c-c4533f32adb6

more screencasts here:

http://www.screencast.com/users/HutongGames/folders/PlayMaker

If so, what don't you like about it?

Cybershead

  • Playmaker Newbie
  • *
  • Posts: 7
Re: 3rd Person Character Movement
« Reply #2 on: March 12, 2012, 04:25:05 PM »
Hi justifun,

I think the best thing i can do is make the controller and put them on my site to show you the difference i cam looking for. Thank you for answering my post, will post as soon as i can this week with links.

Cybershead
If the path of life was made for us, why do we try so hard to change it?

Cybershead

  • Playmaker Newbie
  • *
  • Posts: 7
Re: 3rd Person Character Movement
« Reply #3 on: March 15, 2012, 04:26:59 PM »
have you watched the 3rd person controller playmaker video?

http://www.screencast.com/users/HutongGames/folders/PlayMaker/media/e73a91a6-8b33-4e6a-8e4c-c4533f32adb6

more screencasts here:

http://www.screencast.com/users/HutongGames/folders/PlayMaker

If so, what don't you like about it?


Hi Justifun,

I uploaded my movement that i like and think you cannot do in Playmaker, i know the animation on the jump borked but you get the idea. If you can do this in Playmaker please tell me as when i used the Tutorial my movement was strange.

http://www.unitygamedev.co.uk/gametest/unity/index.html

Thanks

Cybershead
If the path of life was made for us, why do we try so hard to change it?

justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 280
Re: 3rd Person Character Movement
« Reply #4 on: March 15, 2012, 08:39:09 PM »
Yeah you can totally do that.

Take a look at this screen shot.

Create a cube
Parent your Camera to the cube

Add an FSM to a cube
Create 2 float variables called "HorizontalAxis" and "VerticalAxis"
Use 2 "Get Axis" actions and label the axis names "Horizontal" and "Vertical" (same names as the player input button names)

Increase their multipliers to 2 to make him move faster

Add a translate action and use the "VerticalAxis" variable as the "Z" value
Add a rotate action and use the "HorizontalAxis" variable as the "Y" value

Make sure "Every frame" is checked for both of them.

Voila!

Your cube moves around exactly like your demostration webplayer you posted.

In order to blend the animations, I'd create a second fsm on you cube.

Make the 2 VerticalAxis/Horizontal Axis variable global variables by putting them in the Global Variable section instead

Then on your few FSM, you would use a float compare to check if those variables are equal to 0 or a positive or negative number.

eg: If Vertical Axis is zero then goto a state where you play the idle animation
If Vertical Axis is Greater than 0, goto a state where you play the walking forward animation
If Horizontal is greater than 0 - goto a state where you play the turn right animation
etc etc etc

Try it out and let us know if its the way you were thinking



Cybershead

  • Playmaker Newbie
  • *
  • Posts: 7
Re: 3rd Person Character Movement
« Reply #5 on: March 16, 2012, 08:09:02 PM »
Heya Justifun,

Thats great thank you, i have new faith in PM. But one problem.. Its late and i have not uploaded to my site. but i find that the character will walk on one height and will walk through the mountains, i tried adding gravity etc but it still did the same. Do you have an answer for this? If you need me to upload i will. But i am sure a God of PM will know :)
Thank you for taking your time to help me, i am indented.

 ;D I added a Motor and now it bounces along the surface, i will work on this some more see if i can figure this out. Will upload if i cannot figure this out.


Cybershead
« Last Edit: March 16, 2012, 08:30:19 PM by Cybershead »
If the path of life was made for us, why do we try so hard to change it?

justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 280
Re: 3rd Person Character Movement
« Reply #6 on: March 18, 2012, 12:14:16 AM »
I went ahead and made a video tutorial setting up a cube exactly the way your scripted example was made, but with playmaker.

bump it up to 1080P and full screen it to be able to read things clearly.

enjoy!

Edit: Link Fixed

let me know if you have any questions
« Last Edit: March 18, 2012, 12:09:29 PM by justifun »

terrymorgan

  • Junior Playmaker
  • **
  • Posts: 65
Re: 3rd Person Character Movement
« Reply #7 on: April 16, 2012, 12:29:27 PM »
quote
bump it up to 1080P and full screen it to be able to read things clearly
unquote

I could only get 720, could you post the .unity file please?

Elizeusz

  • Playmaker Newbie
  • *
  • Posts: 32
Re: 3rd Person Character Movement
« Reply #8 on: April 17, 2012, 03:24:37 AM »
Very good tutorial thank you ! :)

terrymorgan

  • Junior Playmaker
  • **
  • Posts: 65
Re: 3rd Person Character Movement
« Reply #9 on: April 17, 2012, 11:16:07 AM »
K, I have it working sort of, missing all the animations so it's hard to test jump, etc. but I'm not
getting any running when I press left-shift. BTW, justifun, how you came up with this is mind-boggling,
thank you.

http://terrymorgan.net/3rd_person_justifun.unity
69k

Elizeusz

  • Playmaker Newbie
  • *
  • Posts: 32
Re: 3rd Person Character Movement
« Reply #10 on: April 17, 2012, 03:40:21 PM »
Hi i have one question. Everything is workin very good for me. But i have some problem with jumping. My character is jumping but when i press left arrow or right and then left ctrl for jumping and then still presing left arrow but not ctrl my character is sliding on the ground not walking or running.

1) ctrl is for jumping
2) arrows ( left , right ) for walking
3) space for running
4) left and right arrow plus ctrl = jump but after that my character i sliding not walkin when he landed

My english is not good but i hope You will understand :)

justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 280
Re: 3rd Person Character Movement
« Reply #11 on: April 17, 2012, 04:39:00 PM »
After your character jumps you need to transition back to a state where he is walking or running again.

Elizeusz

  • Playmaker Newbie
  • *
  • Posts: 32
Re: 3rd Person Character Movement
« Reply #12 on: April 18, 2012, 12:48:06 AM »
Can You explain me how to do this between two FSM. Walk and run is on the first FSM and jump on second one. Or how to use global transition? I have problem with global transitions not sure how they work.

justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 280
Re: 3rd Person Character Movement
« Reply #13 on: April 18, 2012, 10:33:33 AM »
I've been playing around with another method for setting up a 3rd person controller, ill put together a new video when its good to go, but in the mean time, it might be easier to put the jump stuff in with the other walk/run animation section.

Global Transitions area easy to setup. 

In the events tab, make sure you you check the box labelled "global" next to the event you want to create

Now make a new state in your FSM and right click it and choose "add global transition"

Then pick your newly created global event.

Now at any point in that FSM or any other FSM you can use the action "Send Event" or "Send Event on FSM" and you can specify the name of that new global event you created, and the FSM will instantly jump to that state no matter where it is the FSM. 

So you could create one for jumping in the same FSM as the run/walk.....
the run/walk will be connected and go back and forth between each other like in the example.

Create a new Jumping State with a global transition starting it, and an action that plays your animation of your jump on it.  Upon "finished" it should go back to your run or walk, which ever you choose.

Now, on a NEW FSM separate from all of this we'll create a single action that looks for the jump key to be pressed (get key down).  And when it does, it will fire off a second state that will uses the "SEND EVENT" action and will trigger your "jumping" global event back on your run/walk FSM.  We separate this jumping button watching idea onto a different FSM so that it can be running all the time waiting for your jumping button.  Or else you would have to check within every state in your run/walk actions for the jump button.Its just going to be a input manager or watcher if you will.

Hope this makes all makes sense. please feel free to  ask more questions if you need to.


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: 3rd Person Character Movement
« Reply #14 on: April 18, 2012, 11:32:01 AM »
Hi Justifin,

 Could you share an actual package of your set up ( minus the playmaker dll of course), then it will be easier to study your example, after having watch the video.

Else, I will make one, no worries.

thanks,

 Jean