So object A collides with object B. Then I want to manipulate a variable from object B using a machine from object A.

The first thing that came to my mind is to set object B as a Selected Object after object A collides. Problem is, how will I implement this?

I have to implement it in a way that it is object A that changes the variable from B, not B itself manipulates the variable because objects A through Z will have different ways of interaction, and simply bombarding B with conditions that detect the identity of the colliding object (Is it object A? C? D? ETC) will make it clunky.

Sorry newbie here. Thanks!
  • Well, you can also do it this way. To change an object variable in object B, in the object A trigger machine, just add in the change variable node, set variable origin to Object, type in the variable you want to change into the variable key, and in the object section, just put in starting object.
    The starting object is whatever object that collides with object A. So whether it's object B or Z, the moment it collides with object A, that object will be the starting object. Of course, the limitation of such method you want is that all object variables of the gameobject A to Z must have the same object variable name.

    If they are different, you will have to do it the long way, and in the object A trigger machine, you will have to add in the check object name node, and changing their respective object variables upon success.
  • edited May 23
    Neat, that will work just fine. I'm confused, however, by what will the starting object be for other types of machines. For instance, if it is an interaction machine. Will it be the game object with the interaction machine component? Thanks again!
    Post edited by Morpheus on
  • Generally, the Machine Object is the game object the machine is running on (usually where the component is added to), the starting object is the one that started the machine, e.g. through colliding with the machine object or interacting with it.
    Since interactions can only be caused by the player, the starting object of an interaction machine is usually the player's game object.

    For your desired setup, using what @Shadow_Fire explained should be enough. For anything more complex, e.g. each object playing different animations or spawning prefabs or whatever, you'll have to use trigger machines on those game objects.
    If you're enjoying my products, free updates and support, please consider supporting me on!
  • Cool. Thanks @gamingislove ! And yes, @Shadow_Fire 's will work just fine.
Sign In or Register to comment.