Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: ColeBK on November 27, 2013, 01:14:03 PM

Title: 3rd person issue
Post by: ColeBK on November 27, 2013, 01:14:03 PM
Hi!

I've setup a simple 3rd person character control(like the in in huttong games tutorial). I've attached the Main Camera to the character.
Works fine, except one thing: When I move backwards, the camera goes crazy, it starts to make small but fast rotations left to right - right to left.

Can anyone help me with this?

Thanks.
Title: Re: 3rd person issue
Post by: colpolstudios on November 28, 2013, 03:23:19 PM
Hi, I think this is were your issue lies.

"I've attached the Main Camera to the character".

If you re watch the tutorial the main camera looks at the character and is not attached to it.

one thing to watch out for is ensure the tool handles are in local and not global if you want to view the character rotating and facing in the z axis.

One thing I have noticed and am unsure why.

when I select a new direction the capsule rotates to face the new direction but there is a pause of maybe 1 second before I move in the new direction.

I do not notice this on the tutorial possibly someone with more experience could answer why.

edit: I had a cube attached with a box collider once I removed this everything worked.

Hopefully if you un parent the main camera from the character this will solve your issue.
Title: Re: 3rd person issue
Post by: ColeBK on November 29, 2013, 01:28:41 AM
I don't want to detach the Camera, as it has to follow the player character. BTW,
I've seen this method of following the character with the camera by attaching it, in an other hutonggames tutorial.

Thanks anyway. Any other suggestions?
Title: Re: 3rd person issue
Post by: colpolstudios on November 29, 2013, 05:05:45 AM
I've seen this method of following the character with the camera by attaching it, in an other hutonggames tutorial.

could you post a link to this tutorial please
Title: Re: 3rd person issue
Post by: ColeBK on November 29, 2013, 05:18:15 AM
Sure:
Title: Re: 3rd person issue
Post by: colpolstudios on November 29, 2013, 03:26:34 PM
Thank you so much I did not know of any of these tutorials.

I am now subscribed and will watch and learn.

Title: Re: 3rd person issue
Post by: Breadman on November 29, 2013, 11:59:12 PM
Something you might be interested in trying is the "smooth follow" PlayMaker action. I have a third-person camera that follows the character, and rather than parenting it to the character, the action takes care of all that.

I understand that you like the setup you have (especially since it coincides with the tutorial you're watching so it's easy to follow the tut), but if you reach a dead end, give the smooth follow action a shot.
Title: Re: 3rd person issue
Post by: ColeBK on November 30, 2013, 01:28:08 AM
I tried the smooth follow, but now when I press backwards direction, the camera starts to rotate around the character.

Any idea, why is it happening?
Title: Re: 3rd person issue
Post by: Breadman on November 30, 2013, 01:38:48 AM
I had this issue for a while when I was developing my character controller - all the movement directions worked fine, except for moving backwards (towards the camera) . It all depends on how your other actions are setup. It sounds like you might have another FSM or action which is moving the character relative to the camera. The tutorial you're following relies on you setting things up exactly the way they do, so when you change just one part of the setup, you get unusual results sometimes.

Try poking around the FSMs responsible for the camera, as well as the FSMs responsible for the character, and see if you can intuit what might be the cause. For me, it was a matter of changing a few lines in the character controller script (not something I'm talented at or comfortable with, by any means, but it worked eventually).

If that sounds scary or if you still have trouble, there's a series of tutorials that setup a similar third-person controller, that you may or may not be interested in looking at:

http://www.youtube.com/watch?feature=player_embedded&v=od78RhlLXUI#t=2

There's a whole series of these on the site (you've probably seen them):

http://www.hutonggames.com/tutorials_getting_started.php

But the one I linked was really useful for getting me started with a basic camera-aware character controller. I just spent the last few weeks wrestling with my character controller and associated scripts (ugh), so let me know if I can help you any further!
Title: Re: 3rd person issue
Post by: ColeBK on November 30, 2013, 01:44:01 AM
I used the same tutorial that you linked, and all I did in addition is to set up variables for Mecanim animations. I have no idea what can cause this issue.
Title: Re: 3rd person issue
Post by: Breadman on November 30, 2013, 01:47:12 AM
Yeah, I know that exact frustration.

Can you describe, or take screenshots of, your FSM structure perhaps? Are you using any scripts on the character in addition to the PlayMaker FSMs? (I find that combining the two can sometimes take a little extra effort)
Title: Re: 3rd person issue
Post by: ColeBK on November 30, 2013, 03:03:49 AM
I've attached a screenshot of the actions controlling movement. The other actions in the FSM are Set Animator (Variable) actions.
Title: Re: 3rd person issue
Post by: colpolstudios on November 30, 2013, 05:38:21 AM
hello sorry to jump in but possibly you may be able to help me.

How did you take the global movement vector 3 and use this as variables in set animator actions?

I am trying to do a similar thing using get axis vector the global movement and then store the x as x axis and z as z axis these are local values that are exposed in the inspector.

I do this every frame, but the values are always changing when you are moving.

Could you post a screenshot of the FSM were you use the set animator variable please.



Title: Re: 3rd person issue
Post by: ColeBK on November 30, 2013, 05:57:29 AM
Of course, I've attached the screenshot.

Keep in mind that the "Direction" and "MoveSpeed" variables are created in Mecanim AND in the FSM. The variables in Mecanim and in the FSM have nothing to do with each other, unless you link them the way I did. I'm writing this, because it can be confusing that I'm using the same variable names in Mecanim and in the FSM.

I hope this helps, feel free to ask if something is not clear, I'm happy to help.


Title: Re: 3rd person issue
Post by: colpolstudios on November 30, 2013, 09:51:02 AM
Thank you.

I am confused the get axis vector gets what key pressed and then stores how much in the global movement.

The controller simple move then moves the object in the correct direction.

It seems that I need to setup another get axis vector to detect what direction I am currently going in?





Title: Re: 3rd person issue
Post by: ColeBK on November 30, 2013, 10:55:43 AM
I use the MoveSpeed variable to determine wether the character is moving forward/backwards/idle so I can play the appropriate animation walk animation.

The Direction Variable is used to determine wether the character is turning or not, so I can play the turning animations.

You  have to handle these 2 Axises separately, as they need different animations.

Title: Re: 3rd person issue
Post by: colpolstudios on November 30, 2013, 12:22:48 PM
I have been able to setup a new FSM

I have it setup like your kind example handling the 2 Axises separately.

Horizontal stored in X axis

vertical stored in Z axis

using float compare x axis to zero

is greater than moving right

less than moving left.

using float compare Z axis to zero

is greater than moving Forward

less than moving Backward.

How would I check when both forward and right are pressed?
Title: Re: 3rd person issue
Post by: ColeBK on November 30, 2013, 12:33:58 PM
The FSM setup that I've shown in the first screenshot will handle both Axises, and will move the character.

You only need to setup conditions in Mecanim(For animations), not in the FSM.

Just to make it clear, what it is exactly that you want to achieve? (Not sure if you want to make Mecanim animations as you're talking about a capsule).

Title: Re: 3rd person issue
Post by: colpolstudios on November 30, 2013, 01:03:38 PM
Sorry for the confusion.

I am not using Mecanim(For animations) but would like to use simple sprite pro for my sprite animations not 3d models.

Does the Mecanim(For animations) check in some way for both up and right key press?
Title: Re: 3rd person issue
Post by: ColeBK on November 30, 2013, 01:10:27 PM
Simply add 2 conditions(MoveSpeed, and Direction) in Mecanim for the animation.

I know nothing about simple sprite pro, so I cannot help you with that, sorry.
Title: Re: 3rd person issue
Post by: colpolstudios on November 30, 2013, 01:27:46 PM
Thank you for your very kind help.

I have yet to use Mecanim, but if it can check for both keys pressed there must be a way for me to do it too.

But I can not at present find a way to do this.

Currently I leave the Direction of character when I press only one key

When I press two keys the object does move in the correct direction but only one key state shows as active.

I need to check is forward and right both active possibly I am returning to quickly to the Direction of character state.

I will keep trying
Title: Re: 3rd person issue
Post by: jeanfabre on December 02, 2013, 01:11:06 AM
Hi,

 you can reuse the value you got from the "get axis", or you have a new fsm getting the axis again, nothing wrong with this, especially if you expect concurrent behavior using the same inputs.

bye,

 Jean
Title: Re: 3rd person issue
Post by: colpolstudios on December 02, 2013, 04:31:35 AM
Hi,

 you can reuse the value you got from the "get axis", or you have a new fsm getting the axis again, nothing wrong with this, especially if you expect concurrent behavior using the same inputs.

bye,

 Jean

Hi Jean I have requested help on this issue in a new post,

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