0
Answered

Need Parent from actions and not Invoker, Player or GameObject.

eagleeyez 5 months ago in Game Creator updated by Marti (Lead Developer) 5 months ago 3

Hi I am back, because of some sad times over the last 2 weeks I did nothing here, but I am back again.


Need Parent from actions and not Invoker, Player or GameObject.

Why? In simple words I need for any actions to point to its parent and not Invoker.

Why?

  • Because of action reusability. If you do not get what I mean here then I will make a video.

Example 1 (this is how it is done now and why it is not good)

  1. A door in the scene should open and close on left mouse click
  2. On the door add a trigger as component and not as child object.
  3. Add a condition as child object.
  4. As child of condition add a local variable bool called toggle.
  5. In condition check toggle bool is false THEN action translate rotation and action toggle bool.
  6. ELSE toggle bool action and translate rotation again to start.
  7. In the actions set the target to Invoker.

Now this works as the trigger is the Invoker and is a component of door. But I cannot just copy the condition object with all children to another door as the trigger is on the door object directly.


Example 2 how it should work.

So now instead if I had the trigger and all actions as a child of the door it will not work as the invoker is now the trigger and not the door. So what we need here is in the drop down list instead of Invoker we need Parent. That way this code can be prefabed and reused on other doors as the Trigger, conditions and actions are 1 object as child of door, (door just has a box collider set as trigger)are looking for the parent to rotate and not the invoker which would be trigger..

In simple words I need for any actions to point to its parent and not Invoker.

Unity version:
2019.3.0f3
Game Creator version:
1.1.6

Answer

Answer
Under review

This is an interesting question. The point you make is very valid, and I have experienced this myself. The problem is that the Invoker (or more precisely, the list that appears with it) is a fixed one and can't be modified without breaking compatibility with other modules.

I've been investigating how to approach this differently for the next Game Creator major iteration, where the Invoker part will simply disappear and be replaced by two new values: Self and Target. Self will always reference the object with the Trigger and Target, if it makes sense, will reference the object responsible for calling the Trigger.

For example, a "On Collision Enter" will have the Self reference the Trigger and Target the object colliding.

However, because the list won't be hardcoded, it will use a new feature called polymorphic serialization, which is available in 2020.1 (with a full assortment of bugs, since it's brand new). This will allow us to dynamically add new options to the list, even in different modules, that complement these.

For example, we could then easily add the "Self Parent" and the "Target Parent" without much of a hassle.

However, this is will only be possible once the Unity's feature counterpart is stable enough so we can develop Game Creator on top of it. I'm open (and eager!) to discuss how this sounds or if you have suggestions on this.

Sorry for the bummer though, since this means it's not possible to do this on the current version.

PS: Hope you're doing fine.

Answer
Under review

This is an interesting question. The point you make is very valid, and I have experienced this myself. The problem is that the Invoker (or more precisely, the list that appears with it) is a fixed one and can't be modified without breaking compatibility with other modules.

I've been investigating how to approach this differently for the next Game Creator major iteration, where the Invoker part will simply disappear and be replaced by two new values: Self and Target. Self will always reference the object with the Trigger and Target, if it makes sense, will reference the object responsible for calling the Trigger.

For example, a "On Collision Enter" will have the Self reference the Trigger and Target the object colliding.

However, because the list won't be hardcoded, it will use a new feature called polymorphic serialization, which is available in 2020.1 (with a full assortment of bugs, since it's brand new). This will allow us to dynamically add new options to the list, even in different modules, that complement these.

For example, we could then easily add the "Self Parent" and the "Target Parent" without much of a hassle.

However, this is will only be possible once the Unity's feature counterpart is stable enough so we can develop Game Creator on top of it. I'm open (and eager!) to discuss how this sounds or if you have suggestions on this.

Sorry for the bummer though, since this means it's not possible to do this on the current version.

PS: Hope you're doing fine.

+1

Bingo, that will be it. 

For the mean time I use Invoker and just place the trigger as a component on the object and all other stuff are as one child and children within. So no seperate Trigger object.

OR if I need 100 windows that open and close I make one with the functionality and then just prefab that to reuse. If I then have 100 doors I use the same condition/action child but just add a trigger component to the door and prefab that too. 

And thanks I am fine now and will get back to making the video tutorials. 

Which I am starting again as I will be going through each module with GC at the same time.

I am still learning everything myself but getting there slowly but surely.

Answered

Thanks for understanding :-) Looking forward watching more tutorials! They are very insightful!