playMaker

Author Topic: [SOLVED] Loot 'Throwout' sequence 5  (Read 2617 times)

k2kshard

  • Playmaker Newbie
  • *
  • Posts: 9
[SOLVED] Loot 'Throwout' sequence 5
« on: June 24, 2012, 05:06:39 AM »
Hi All,

Am new to all this so excuse me if its a simple issue :)

I have an object (A Bin) that when the player enters the trigger it drops a random type, and random # of loot.

This is all setup fine and works perfectly, at the moment it just creates the loot object (a prefab) and spawns it in a specific location (Using create object)

What I would like to do is to get the loot to Pop out/Fly out in a random manner and land on the ground, but I am having some issues in getting anything replicating this kind of action working.

Does anyone have some pointers for me on how to achieve this action?

Thanks
« Last Edit: June 25, 2012, 09:10:12 AM by Alex Chouls »

Red

  • Hero Member
  • *****
  • Posts: 563
Re: Loot 'Throwout' sequence
« Reply #1 on: June 24, 2012, 06:10:17 AM »
i've made something similar...

make an int for how many objects you want to have spawn... if you want it to be random, make it a random with a "Random int" action

then, create two random floats. assign the random floats to the X and Z of a "set vector3 XYZ" action and set the Y to a hard coded value that sits just above the pivot point of the object spawing them... drop this into a vector3 variable.

next, create the object you're going to spawn as a prefab with a rigid body (so you can get the gravity effect) and store it in a gameObject variable.

then, add a force with the origin at the pivot point of the object that's spawing them and make it apply the force to the recently spawned object. you might have to play around with the variables a little bit to figure out which strength and type of force is appropriate for what you want to make happen.

subtract 1 from the number of objects int that you declared at the start

loop back until the int you created equals 0 so you can spawn as many as you need.

here's hoping this helps or at the very least gets you on the right track.

you will probably have to tell the spawned objects to ignore the "chest/spawner" object in the Edit>Project>Physics setting. you can create a layer for these spawned objects and have them only interact through the physics engine by telling that layer to only interact with the "floor" or "walls" layer if you have those defined.
« Last Edit: June 24, 2012, 06:13:24 AM by Red »

k2kshard

  • Playmaker Newbie
  • *
  • Posts: 9
Re: Loot 'Throwout' sequence
« Reply #2 on: June 24, 2012, 07:30:31 PM »
Hi Red,

Thanks for that - Should be right to get that sorted!

One thing I was having issues with before I made this thread - I had applied a rigid body to my prefabs but they would just fall through the ground?

It was odd as I tested by creating a new cube then using rigid body on that and it worked fine, but my item prefabs (which are a trigger (with playmaker stuff) parented to a mesh) it would always fall through the ground..

Any ideas?

Red

  • Hero Member
  • *****
  • Posts: 563
Re: Loot 'Throwout' sequence
« Reply #3 on: June 24, 2012, 07:49:21 PM »
first thing is to make sure that they have a collider on them... past that, making sure that the physics settings know to have then interact with things like the floor (the physics settings is so that they don't collide with the chest that they're spawning from as that'd make them react rather wildly.) if the collider is set to be a trigger, consider nesting an empty gameObject as a child of the object to act as the trigger (with  a collider component set as a trigger.)
« Last Edit: June 24, 2012, 07:52:04 PM by Red »

k2kshard

  • Playmaker Newbie
  • *
  • Posts: 9
Re: Loot 'Throwout' sequence
« Reply #4 on: June 24, 2012, 09:26:06 PM »
Ok I was halfway though a reply here and seemed to have fixed my issue...

If i setup the GameObjects Trigger Event-> Collide Tag to be the Player it seems to work fine now!

Thanks for the help :)!