playMaker

Author Topic: Controller Switch  (Read 8224 times)

numonic

  • Playmaker Newbie
  • *
  • Posts: 33
Controller Switch
« on: May 01, 2012, 04:05:10 PM »
First of all awesome forum you guys are great! I have a character I'm working that can Run,Jump,Walk, Convert to jet mode,Shoot,Strafe left forwards backwards pretty much front back left and right.

Now I made the controller based on the tutorials for Animation Graph1,Animation Graph2, and simple 3rd person controller.

I would like to have the character while in jet mode to be controlled with the controller that was made on the move section. But when I move the character once he's transformed into jet mode. It jumps back to the idle state.

Does anyone know a good way to keep those controls and then add some height?
I would like the jet to fly up and roam around and when he transforms back he then falls back onto the ground plane?


justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 280
Re: Controller Switch
« Reply #1 on: May 01, 2012, 08:58:50 PM »
Not 100% sure about how to setup the move without seeing your graph, but you can switch him to a new height simply by using the "set position" action in the Y value to lock him to a new height (provided you arn't using gravity) whenever he's in jet form.


numonic

  • Playmaker Newbie
  • *
  • Posts: 33
Re: Controller Switch
« Reply #2 on: May 02, 2012, 10:25:00 AM »
Sounds interesting how do I turn off the gravity when he is in jet mode on the controller?

justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 280
Re: Controller Switch
« Reply #3 on: May 02, 2012, 10:54:45 AM »
Depending on how you have things up, you might be able to either use the "set gravity" action
or you might have to adjust the gravity using the "character motor" action and set it to 0.


numonic

  • Playmaker Newbie
  • *
  • Posts: 33
Re: Controller Switch
« Reply #4 on: May 06, 2012, 01:32:04 AM »
Here are some screen shots of the current fsm diagram of the various fsm used to make the character transform and move.
I would need to have some help on an approach to having the character be able to be controlled with the figure in jet mode with the current moving controller set up.

Animationfsm
controllerfsm
transformfsm

amaranth

  • Full Member
  • ***
  • Posts: 172
Re: Controller Switch
« Reply #5 on: May 06, 2012, 09:50:31 PM »
I've not figured out how to turn off gravity for a character controller. Even when gravity is set to 0, gravity is still present. Watching this thread in case someone figures out how to disable it w/o disabling the character controller.

justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 280
Re: Controller Switch
« Reply #6 on: May 06, 2012, 11:01:09 PM »
I was just about to quote you amaranth with your "set motor gravity" script.  It worked great for me when i used it.  However i used it with a combination of "set position" to lock my character at a specific height, then turned off gravity and it worked well, he hovers at that height now.

You can track his "y" position every frame, then when you press a button lets stay , he turns off gravity and sets his y position to his last y position height.  Now he should hover at that height.

then when you want to regain gravity, simply switch to a state with your set gravity back to whatever your normal gravity is, and he starts falling again.

justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 280
Re: Controller Switch
« Reply #7 on: May 06, 2012, 11:08:36 PM »
I just looked over your initial question again numonic.

There's 2 different ways you could approach the movement stuff.

One would be to create 2 different "move" states. One for while on ground and one for while flying in jet mode.

Then simply switch between which one you want depending on his transformation state.  This way allows you to tweak the settings differently depending on what mode you are in. eg: sensitivity / speed etc.

The other way would be to have a state before you get to your "move" state, that checks which mode the player is in, tweaks the settings then applies those to your movement. 

eg: if flying then speed should be 10

as for the height stuff, try out what i did in my previous post above this one.

Grab the "set motor gravity" action from this thread
http://hutonggames.com/playmakerforum/index.php?topic=1392.0

add that to the state that he starts in his "jet mode" and set gravity to 0, then use a "set position" action right afterwards, and set the value to whichever height you want the jet to fly at. 

when you want gravity to take over again, use the set motor gravity again and make its value 20 or whatever is your default.


numonic

  • Playmaker Newbie
  • *
  • Posts: 33
Re: Controller Switch
« Reply #8 on: May 06, 2012, 11:22:19 PM »
I will definetly try this out thanks! Will be letting you guys know about the progress I'm currently rendering some screengrabs of in game progress with the character showing the FSM tree and all it's goodies again thanks for the help all greatly appreciated!

numonic

  • Playmaker Newbie
  • *
  • Posts: 33
Re: Controller Switch
« Reply #9 on: May 07, 2012, 08:31:58 AM »
I have posted up a video with the game in motion showing the FSM tree and everything I've used to make the character hopefully it'll be able to help you guys help me.


Thanks.

https://vimeo.com/41680195

justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 280
Re: Controller Switch
« Reply #10 on: May 07, 2012, 08:42:25 AM »
Right off the bat,the reason why he's not walking is that in your first state there's a play animation and the animation is set to "idle".

There also appears to be some sort of error on your last state on the capsule. you should fix it or disable that action, it might be causing other headaches for you.


Since you have all of your running/walking/flying states on the actual model seperate from the capsule, what you would actually want to do, is instead of using "play animations" on the capsule. you would replace those with "send event" actions and change "self" to FSM on game object, and point it towards your character model.

so when he's walking the state would send an event (you called it "walkstate").  This would signal the other FSM to switch him to play the walking animation.

Does that make sense?

The capsule is watching for incoming inputs but signalling the character model prefab where you have all of the separate states which will control the various animations.


justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 280
Re: Controller Switch
« Reply #11 on: May 07, 2012, 08:52:00 AM »
More thoughts.....

Depending on if your flying dude is going to stay at a particular altitude or be able to fly around freely in the air. Things might get a bit more complicated.

I haven't tried making a plane yet before, but here's how i believe it works.  Perhaps someone else with more experience can help out.

If he's going to be able to fly freely in the air, then you need to disable the character controller when in jet mode and he will become a normal rigid body.  His momentum will need to be controlled via add force. and he will be "pushed" through the air.  As you tilt the joystick it will rotate him up down left right and since the force will always be coming from behind him, he'll fly around.

I think that's how it will work.  Try it on a new scene with a cube first, then save the FSM as a template when you have it working and apply it back to your robot dude.


amaranth

  • Full Member
  • ***
  • Posts: 172
Re: Controller Switch
« Reply #12 on: May 07, 2012, 11:10:29 AM »
However i used it with a combination of "set position" to lock my character at a specific height, then turned off gravity and it worked well, he hovers at that height now.

Ahhhhh, I don't think I was using Set Position. I'll go try it out! :)

justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 280
Re: Controller Switch
« Reply #13 on: May 07, 2012, 11:13:38 AM »
Another thought would be to switch controllers from the controller simple move, to "translate" when you go into jet mode, then gravity won't affect the controller.  i think i came across that once, but im not near my dev machine right now to try it.


numonic

  • Playmaker Newbie
  • *
  • Posts: 33
Re: Controller Switch
« Reply #14 on: May 08, 2012, 10:38:04 AM »
I was having trouble having the character jump the way he was doing. So I pretty much started from scratch again. I have made the character run after a certain point when you press walk which is nice.
I am also for some reason having trouble getting the error removed in the transformFSM.

But still having trouble having the character maintain it's jet mode. Is there away you can make a jpeg or something so I can see what actions to apply in the fsm maybe I'm doing something wrong. I will upload a
screencast of my new workings and freshly done FSM tree for the movecontrollerfsm and animationfsm.

Greatly appreciating the help I'm getting with it I wouldn't have gone this far.

Thanks!