playMaker

Author Topic: Prefab Spawning Under Spawn Position. [SOLVED]  (Read 4433 times)

MaskedPixel

  • Playmaker Newbie
  • *
  • Posts: 4
Prefab Spawning Under Spawn Position. [SOLVED]
« on: April 03, 2012, 05:51:46 PM »
I am instantiating a prefab in a way nearly identical to the Throw Grenade Example.  The only differences are the spawn position GO is attached to the capsule instead of a Main Camera as this is third person view and there is no FSM on the grenade.

It starts out spawning in the right position and the grenades fly off into the distance.  Then the spawns keep getting lower and lower until they spawn inside the floor even though the y-value of the spawn position GO never changes and there is plenty of room between the spawn pos and the capsule.  I have no idea what I am doing wrong...

Any suggestions/ideas are appreciated...
« Last Edit: April 03, 2012, 09:08:23 PM by MaskedPixel »

iHaveReturnd

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Prefab Spawning Under Spawn Position.
« Reply #1 on: April 03, 2012, 07:28:37 PM »
Does your spawner object have a collider on it?  It could be colliding with the grenades when they spawn and pushing the spawner down each time.  I had a problem like that with a past project.

Based on how you described it I don't think that's the problem but its something to double check.

You might be able to add a rigid body to it if it doesn't have one, and go to constraints in the inspector window and lock the y position.

If that doesnt work, a work around would be to make it set its y position relative to the capsule everytime it fires though that certainly wouldn't be the most efficient thing.

Sorry I don't have a more concrete answer but I can't tell what would be causing it unless its a collision, FSM, or script attached to it or a relating object.

MaskedPixel

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Prefab Spawning Under Spawn Position.
« Reply #2 on: April 03, 2012, 08:36:39 PM »
Thanks for the suggestions.

I double checked that the spawn location was far enough from the capsule by moving it to where it is nowhere near anything else.

Also, I added a rigid body and locked the y value.  The problem persists.

I don't actually know how to make the prefab spawn at a position relative to the player but I am imagining that that isn't going to make a difference.

Maybe rebuilding everything from scratch will allow me to get it right...

MaskedPixel

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Prefab Spawning Under Spawn Position.
« Reply #3 on: April 03, 2012, 09:08:10 PM »
So this just got rebuilt from scratch and it works great.  I deleted the other scene already so I don't know what I was doing wrong previously, otherwise I would post it here...

SirNikkolas

  • Playmaker Newbie
  • *
  • Posts: 9
Re: Prefab Spawning Under Spawn Position. [SOLVED]
« Reply #4 on: April 03, 2012, 09:39:56 PM »
I had the same problem. Rebuilt it, and it stopped. Idk why it happened the first time, and I have not been able to replicate it. Idk I guess its just a random bug.

justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 280
Re: Prefab Spawning Under Spawn Position. [SOLVED]
« Reply #5 on: April 03, 2012, 09:51:08 PM »
You can make something spawn relative to another object by setting the spawn point to your player's position and also add a value in the "position" drop down (it will be relative to the "spawn point" object.

MaskedPixel

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Prefab Spawning Under Spawn Position. [SOLVED]
« Reply #6 on: April 04, 2012, 09:22:00 AM »
You can make something spawn relative to another object by setting the spawn point to your player's position and also add a value in the "position" drop down (it will be relative to the "spawn point" object.

Thanks for the quick tip :D  I had actually tried to spawn this way initially but never figured it out.