playMaker

Author Topic: Give prefab different force values (intensity)? Worms style.  (Read 1850 times)

manu_d

  • Playmaker Newbie
  • *
  • Posts: 2
Give prefab different force values (intensity)? Worms style.
« on: April 04, 2014, 02:31:02 AM »
Hi!

So im developing a 2.5D platformer and I need to create a system in which the player shoots something, and adds force to it depending on the amount of time the key was pressed (worms or golf/soccer style).

I've set up an FSM inside the player which tells the bullet to instantiate after key release and also adds to an int per second + every frame on key press. Now, when I have to give the bullet the stored global variables nothing happens. I guess it is a communication issue regarding objects and prefabs.
Is there any workaround on this issue? Has somebody gone through this and knows where to go from here?

I hope someone has the answer because this is a major buzz killer!
Thanks.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Give prefab different force values (intensity)? Worms style.
« Reply #1 on: April 04, 2014, 07:50:20 AM »
Hi,

 Are you trying to reference scene object on a prefab in your assets? that's indeed a Unity restrictions.

 for this, you need to do it at runtime, when you instantiate that prefab. Have the prefab either get the variable from a global variable or the spawner store the reference of the newly created instance of that prefab to set one of its fsm variable.

 Does that make sense? else I am not sure what is the problem you are facing.

bye,

 Jean

manu_d

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Give prefab different force values (intensity)? Worms style.
« Reply #2 on: April 04, 2014, 03:16:31 PM »
Thanks for the reply!

What you mentioned is exactly what I'm doing, but the prefab is ignoring the global variable for some reason. At Start, the prefab has an Add Force which grabs the global float/int, but instead of aplying the force it drops and is only affected by gravity. Then I tryed setting the prefab's Vector3 from the spawner, and it kept dropping when instantiated. I really don't want to do this in code because then I wouldn't be able to interact with this system form another FSM (like playing sounds or triggering animations and stuff)... Any ideas?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Give prefab different force values (intensity)? Worms style.
« Reply #3 on: April 08, 2014, 07:45:47 AM »
Hi,

 prefabs don't just ignore global variables, I never encountered that case, so I would say that you may have a problem of logic implementation.

 can you debug and watch the value of your global variable, maybe it reads properly the global, but the value itself is wrong. Could that be the case?

Maybe it's too son in the lifetime of the prefab as well, when are you using this value? straight on START?

bye,

 Jean