Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: lioncirth on June 10, 2013, 09:19:19 AM

Title: Spawn Points and Spawning The Player
Post by: lioncirth on June 10, 2013, 09:19:19 AM
Hi

I am trying to set up my player spawning but its not working correctly and cannot seem to get it to work.

I have my health set up and when the health = 0 the player will move to the spawn point.

I create a cube and when the player walks through it does an on trigger and sets the object owner as "SpawnPoint"

When the players health goes to 0 I am trying to move the player object to the "SpawnPoint".

I have used translate, Itween move to etc.

I have gotten the player to move but for some reason it must falls through the ground.

I have then tried to despawn it and respawn the player which works but for some reason the controls no longer work....

Any help on this would be great
Title: Re: Spawn Points and Spawning The Player
Post by: Lane on June 10, 2013, 09:56:10 AM
You are probably moving the player to a point that is clipping the ground, so he falls through it.

Move the spawn point higher, so when the player moves to that position he falls onto the ground. Also I would probably just use set position.
Title: Re: Spawn Points and Spawning The Player
Post by: lioncirth on June 10, 2013, 10:24:27 AM
Hi

Thanks I have given this ago but it seems to not work.

I have created an empty object that is set up as a trigger, when the player enters it sets the XYZ values as floats "SpawnPoint_z" etc through the use of Get Position action

I have then set when health equals 0 the set position is set as these float values, however the player simply falls through the ground where they are.... it doesnt move them to were I used Get Position...

Thanks
Title: Re: Spawn Points and Spawning The Player
Post by: lioncirth on June 10, 2013, 10:28:49 AM
Okay I can stop them falling through the ground by putting 5 as the Y value, however the player still wont go back to the position I set using "Get Position"...

Thanks for any support :)
Title: Re: Spawn Points and Spawning The Player
Post by: Lane on June 10, 2013, 10:34:06 AM
Get position is for getting the position that the object is currently in.

Set position is for assigning a new position for an object.
Title: Re: Spawn Points and Spawning The Player
Post by: lioncirth on June 10, 2013, 10:40:11 AM
Ah I see

How would I go about getting it to go back to a specific point?

Thanks
Title: Re: Spawn Points and Spawning The Player
Post by: Lane on June 10, 2013, 10:53:16 AM
Store the point.

If your character is walking across a trigger then store the trigger gameObject or Vector3 in a SpawnPoint variable and in your respawn FSM use a Set Position action to define the new coordinates of the Player to that SpawnPoint variable, either a gameObject or Vector3.

If you want to go somewhere else then you need to store that point in a variable for later use or explicitly define the coordinates.
Title: Re: Spawn Points and Spawning The Player
Post by: lioncirth on June 10, 2013, 01:35:07 PM
Cheers

Is there anyway it can be done without having to destroy the object? IE simply fade camera and then move player?

Thanks again!
Title: Re: Spawn Points and Spawning The Player
Post by: Lane on June 10, 2013, 02:14:27 PM
Destroy the player? That should be handled as best suits your project really, sometimes the camera is parented to the player and destroying the Main Camera is not a good idea. Better to just fade to black or something like you're talking about and move everything while the player can't see whats going on.
Title: Re: Spawn Points and Spawning The Player
Post by: lioncirth on June 10, 2013, 03:42:27 PM
Yeah Id prefer to just fade the camera out, move the player to a specific place and then fade the camera in, however what im trying to do is not working.

I want the player to be able to walk through a trigger which would set that object to be the spawn point...I am struggling to find the right actions to get it working from there...
Title: Re: Spawn Points and Spawning The Player
Post by: Lane on June 10, 2013, 03:55:10 PM
You can use Trigger Event.

Use it to execute an event and enter a state on the spawn point where you use Set FSM Game Object to reach into the FSM you're using to define the spawn point and it as the SpawnPoint (gameObject) Variable.
Title: Re: Spawn Points and Spawning The Player
Post by: lioncirth on June 10, 2013, 03:59:28 PM
Hey

Thanks

Dont fully understand how that would work?

Sorry If I am getting annoying :)
Title: Re: Spawn Points and Spawning The Player
Post by: Lane on June 10, 2013, 04:11:47 PM
No problem =)

So basically the idea is...

1. You have a trigger and a default SpawnPoint variable defined.

2. You want the trigger to change the SpawnPoint variable to the position coordinates of the trigger.

3. On the trigger collider, check Is Trigger.

4. On the trigger FSM, put a Trigger Event action in an "Idle" or "Start" state.

5. You want to have the trigger in an "Idle" state until the player hits it, then it moves to a new lets say "Set Spawn" state where it changes the position coordinates of the SpawnPoint variable.

6. In your Trigger Event action use Send Event to push into that "Set Spawn" state.

7. In that Set Spawn state, you can use Set FSM Game Object to go to the FSM that has the Spawn Point Variable defined and change it to this trigger object. You'll want to return to the Idle state when the player leaves the trigger area.

So at this point, your player can now walk over the trigger, the trigger will detect the player Tag, throw the send event and run the Set FSM Game Object action that will change the spawn point variable (wherever it is, you could just use a global variable if you wanted).

8. Now when you are respawning the player you simply tell it to move the player to the Spawn Point variable location which your triggers have defined.

Make sense?
Title: Re: Spawn Points and Spawning The Player
Post by: lioncirth on June 10, 2013, 04:24:33 PM
A little bit, I currently dont have any spawn point in the scene

will have a play - Thanks again!
Title: Re: Spawn Points and Spawning The Player
Post by: Lane on June 10, 2013, 04:30:12 PM
Yep, all the Spawn Point is - is either a Game Object (its position) or a vector3 (coordinates) that you store in a variable, so you just need to create a variable and call it the Spawn Point and fill it with whatever data or coordinates you want.
Title: Re: Spawn Points and Spawning The Player
Post by: lioncirth on June 10, 2013, 04:38:59 PM
Hey

Its a lot to ask but is there anyway you could go into detail about setting the initial spawn point, setting up the checkpoint and then moving the player to the check point?

I have tried using itween move, move towards, translate and none of these seem to move the player.

I dont know if I am making a simple mistake  or got it all wrong lol
Title: Re: Spawn Points and Spawning The Player
Post by: lioncirth on June 11, 2013, 04:23:23 AM
I have tried to do the following and I get some results but not the desired ones.

I have created a game object and used Get Owner and set it to PlayerSpawnPoint.

On the health FSM when the player reaches 0 Health I use "Get Position" and select "PlayerSpawnPoint"

I then store the XYZ into variables, after that action I then use "Set Position" and select my player.

What happens is the player spawns at the Y value of the SpawnPoint but the X and Z stay the same..

Think I might be using the wrong actions here :)
Title: Re: Spawn Points and Spawning The Player
Post by: jeanfabre on June 11, 2013, 05:43:58 AM
Hi,

 you do seem to have a conflict of behavior, maybe another fsm also wants to modify
the position or actually set the position.

Have you doubled checked that the position you get is the right one, maybe the positioning it working just fine, but the vector3 is corrupted to begin with.

bye,

 Jean
Title: Re: Spawn Points and Spawning The Player
Post by: lioncirth on June 11, 2013, 05:51:12 AM
OK

I knew this would be the case....Me turning out to look incredibly stupid :P

It turns out my set up was what was causing the issues. I had a Parent Game Object called Player.

The children of this was my character and then the camera.

I disconnected them all and now it seems to work fine....not 100% sure why :P

Thanks Jean

and Id like to thank Lane - you spent a good amount of time trying to help and I really appreciate it :)
Title: Re: Spawn Points and Spawning The Player
Post by: jeanfabre on June 11, 2013, 06:14:36 AM
Hi,

 Nothing stupid, it's just the way it goes most of the time :) there is a lot to look at and mistakes are so easily done, that it's just part of the game, so don't be too harsh on yourself.

bye,

 Jean