playMaker

Author Topic: Spawn Points and Spawning The Player  (Read 12253 times)

lioncirth

  • Junior Playmaker
  • **
  • Posts: 74
Spawn Points and Spawning The Player
« 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

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Spawn Points and Spawning The Player
« Reply #1 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.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

lioncirth

  • Junior Playmaker
  • **
  • Posts: 74
Re: Spawn Points and Spawning The Player
« Reply #2 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

lioncirth

  • Junior Playmaker
  • **
  • Posts: 74
Re: Spawn Points and Spawning The Player
« Reply #3 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 :)

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Spawn Points and Spawning The Player
« Reply #4 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.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

lioncirth

  • Junior Playmaker
  • **
  • Posts: 74
Re: Spawn Points and Spawning The Player
« Reply #5 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

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Spawn Points and Spawning The Player
« Reply #6 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.
« Last Edit: June 10, 2013, 10:54:53 AM by Lane »
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

lioncirth

  • Junior Playmaker
  • **
  • Posts: 74
Re: Spawn Points and Spawning The Player
« Reply #7 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!

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Spawn Points and Spawning The Player
« Reply #8 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.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

lioncirth

  • Junior Playmaker
  • **
  • Posts: 74
Re: Spawn Points and Spawning The Player
« Reply #9 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...

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Spawn Points and Spawning The Player
« Reply #10 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.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

lioncirth

  • Junior Playmaker
  • **
  • Posts: 74
Re: Spawn Points and Spawning The Player
« Reply #11 on: June 10, 2013, 03:59:28 PM »
Hey

Thanks

Dont fully understand how that would work?

Sorry If I am getting annoying :)

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Spawn Points and Spawning The Player
« Reply #12 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?
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

lioncirth

  • Junior Playmaker
  • **
  • Posts: 74
Re: Spawn Points and Spawning The Player
« Reply #13 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!

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Spawn Points and Spawning The Player
« Reply #14 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.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D