playMaker

Author Topic: where to find Throw Grenade example scene  (Read 5248 times)

colpolstudios

  • Sr. Member
  • ****
  • Posts: 370
where to find Throw Grenade example scene
« on: November 10, 2013, 04:42:30 PM »
I am currently working on a project but would like to learn from the Throw Grenade example but I cannot find it.

possibly I over wrote this example as I imported the playmaker custom samples with event data scene.

This event data scene helped me a lot :)

Would someone possibly help me out?

Ideally I would like to import this example into my project so I can use the example to learn from it.

But I no longer have the example within my assets.





jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: where to find Throw Grenade example scene
« Reply #1 on: November 11, 2013, 12:39:54 AM »
Hi,

  A working sample is here:
 http://hutonggames.com/playmakerforum/index.php?topic=4477.msg25721#msg25721

It does more than firing a grenade, it also alignes the projectile to its trajectory, Something you may or may not want in your case, but it's there if you want it.

Throwing a grenage is a "basic" feature in Physics, you simple add a force once to a RigidBody and done. You use the "add force" action.

Have you tried that already? or did you struggle somewhere else?



bye,

 Jean

colpolstudios

  • Sr. Member
  • ****
  • Posts: 370
Re: where to find Throw Grenade example scene
« Reply #2 on: November 11, 2013, 06:50:00 AM »
Hi the example I was looking for uses an animation graph to make the grenade blink.

I would also like to understand issues when working with a prefab.

I am using find game object to store the reference to the prefab and this works well when enabling an FSM, however when trying to Set Property the field is now empty I cannot use the stored reference.

What is the correct way to reference a prefab I need to set the property of a prefab.

property needed is rigidbody constraints freeze all.

First I turn off the fsm script that handles the ball movement and then I freeze the ball.

Currently this will only work with the instance, once I use the prefab I get a max loop exceeded.




jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: where to find Throw Grenade example scene
« Reply #3 on: November 12, 2013, 01:47:29 AM »
Hi,

 are you sure your find action actually found that gameobject?

Storing prefab reference should be done without finding. instead prefer firing a global event "HELLO I AM HERE" or something, for anyone interested to communicate can get the reference of this event sender, that's the best way to go about this.

 so for example, when an enemy prefab is spawend, a fsm on that prefab will fire on start a global event "ENEMY CREATED", your player of anything else in your game that needs to know a new enemy was created and need to keep a reference of it can listen to that event and use "Get event info" and store the "sender" in a gameobject variable.

 WARNING: if you delete that enemy, then the reference will be void of course.

bye,

 Jean
bye,

 Jean

colpolstudios

  • Sr. Member
  • ****
  • Posts: 370
Re: where to find Throw Grenade example scene
« Reply #4 on: November 12, 2013, 01:12:44 PM »
hi,

I tried adding a global event "HELLO I AM HERE" on the ball in the start state.

I used "Get event info" and store the "sender" in a gameobject variable. I put the prefab into this gameobject variable.

Although I can use this new variable when enabling an FSM.

I cannot use this variable when setting a property I can only drag in the prefab.

In my case when trying to use the prefab I keep getting a max loop error.

Everything works up until I try and use the prefab.

I can work around by not using the prefab and never destroying the instance.

I am still looking for the grenade example that uses an animation graph to make it blink.

Any example that uses an animation graph to make the object blink will do.

colpolstudios

  • Sr. Member
  • ****
  • Posts: 370
Re: where to find Throw Grenade example scene
« Reply #5 on: November 12, 2013, 06:22:38 PM »
Hi,

 are you sure your find action actually found that gameobject?

Storing prefab reference should be done without finding. instead prefer firing a global event "HELLO I AM HERE" or something, for anyone interested to communicate can get the reference of this event sender, that's the best way to go about this.

 so for example, when an enemy prefab is spawend, a fsm on that prefab will fire on start a global event "ENEMY CREATED", your player of anything else in your game that needs to know a new enemy was created and need to keep a reference of it can listen to that event and use "Get event info" and store the "sender" in a gameobject variable.

 WARNING: if you delete that enemy, then the reference will be void of course.

bye,

 Jean
bye,

 Jean

I believe I am doing things wrong could possibly post an example?

Edit I seem to be getting somewhere now, could a prefab(clone) hold a game object variable?

I have a special block that traps a trapped ball, both objects are prefabs and will be created when needed.

The block FSM prefab (clone) will need to have the object variable in order to enable the movement on the trapped ball which will also be a (clone) can I do this?

Ok I tried and it worked out well.

I was able to use the blink action with a timer so this part is now solved.

I no longer need the grenade animation graph example.

However my issue still remains with trying to use a prefab and the set property action.

I still cannot get this setup correctly.

I am not able to set the property to the prefab clone.

help needed please
 



 
« Last Edit: November 13, 2013, 03:15:26 PM by colpolstudios »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: where to find Throw Grenade example scene
« Reply #6 on: November 14, 2013, 02:49:30 AM »
Hi,

 Are you trying to reference this prefab clone from itself or from another gameobject?

 Are you aware of the limitation with Unity referencing gameobjecst from prefabs? a prefab can not reference a gamobject outside its own hierarchy.

bye,

 Jean

colpolstudios

  • Sr. Member
  • ****
  • Posts: 370
Re: where to find Throw Grenade example scene
« Reply #7 on: November 14, 2013, 04:25:22 PM »
The prefab clone is being referenced from another game object.

I was not aware of this. A prefab can not reference a gamobject outside its own hierarchy.

So I am trying this:

collision event store the prefab in a game object variable.

ball (nothing in here but waiting for the prefab clone).

I can use this ball variable to enable \ disable a FSM script on the clone.

However I need to use an OBJECT in order to effect the set property action.

I have an OBJECT variable set up with nothing in the variable.

How do I connect from the prefab clone to the OBJECT, so I can set the property on the prefab?

This ball is the only ball that I need to set the property on.

Ideally I want to be able to use a prefab, Currently I have my system setup in such a way I can reuse the instance.

I can save all of the templates used on this ball and simply use them again in a new scene.

But I want to know the correct way to use a prefab with the set property action.

Sorry for taking so much of your time on this, but I want to know.






jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: where to find Throw Grenade example scene
« Reply #8 on: November 15, 2013, 07:12:06 AM »
Hi,

 One way is to use a global variable and then your prefab simply use this global variable, that will work.

The other way is to fire event to the prefab after it's been instanciated, from your OBJECT typically or one fsm that has a reference of both your OBJECT and your PREFAB INSTANCE.

 then your prefab instance catch this event and store the object reference ( either passed in the event data or because it's the sender), in both case use the action "GetEventInfo" to retrieve either the data or the sender of this event.

 then you should be ok.

bye,

 Jean

colpolstudios

  • Sr. Member
  • ****
  • Posts: 370
Re: where to find Throw Grenade example scene
« Reply #9 on: November 15, 2013, 01:25:42 PM »
Hi,

 One way is to use a global variable and then your prefab simply use this global variable, that will work.

The other way is to fire event to the prefab after it's been instanciated, from your OBJECT typically or one fsm that has a reference of both your OBJECT and your PREFAB INSTANCE.

 then your prefab instance catch this event and store the object reference ( either passed in the event data or because it's the sender), in both case use the action "GetEventInfo" to retrieve either the data or the sender of this event.

 then you should be ok.

bye,

 Jean

One way is to use a global variable and then your prefab simply use this global variable, that will work.

This global variable what type should it be?

A game object or just object?

I am finding it quite difficult to understand when working with prefabs.

I am making progress thanks to your help

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: where to find Throw Grenade example scene
« Reply #10 on: November 18, 2013, 01:50:39 AM »
Hi,

 Use a GameObject fsm variable to keep references of your gameobjects and prefab, "Object" is for other assets on your project ( sounds for example)

bye,

 Jean