I'm having a strange problem... in 2D grid battle tutorial, when I move the collider on the princess prefab to sprite child object, the trigger machine does not get triggered by the princess, whatever "start by root" is checked or not, it doesn't work.
When I move the collider component back, the trigger machine works fine again.
I thought that the collider component on child object could not fire OnTriggerEnter2D method, so I mounted a script with only OnTriggerEnter2D method on the trigger machine's object to test it and found that it could trigger.
Am I setting something wrong?

One more question, is there any suggestion about getting in and out of the houses on the tile map? Since there are a lot of houses, I don't think it's a good idea to use teleport...

thanks for your time.
  • Most likely just Unity physics - the trigger doesn't recognize something entering it due to the moving part (via rigidbody) doesn't have a collider.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Thanks for your reply, but why does the OnTriggerEnter2D method fire? I read the source code of Makinom and saw that the trigger machine is also implemented through the OnTriggerEnter2D method...
    The reason for this requirement is that my collider only covers the lower half of the character's body, and if I put it on prefab root, the collider will rotate with root object when character moving.
    Sorry for my poor English, I might not be able to describe it clearly... I wish I could upload a video!

    On another question, I can currently think of expanding the Change Position node, so that it can move to a marker point similar to spawn point, which is identified by id (The tile map of house is located in the same scene, away from the large map). Is there a more recommended solution?
    Thank you for your help!
  • Ah, I found the reason. Because there is no collider on the prefab root, the condition check (startingObject == Maki.Game.Player.GameObject) will return false forever. The solution is to check the "start by other" and add child object name in it. I hope this helps others who face this problem.

    So that just leaves question 2. @gamingislove Please help this noob...
  • A different solution could be adding a collider used as trigger to the root to cause trigger enter and have the collider (not set up as trigger) on the child for the movement blocking.

    As for the Change Position node - the easiest way would be to find that game object you want to move to. You can either use a Find Object type actor or the Search Objects node to search for (active) game objects in the scene by name, tag, components and other filters.
    Use the found object in the Change Position node to move to.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Thanks for the suggestion! I finally looked at Spawn Point's code and implemented a custom node to manage all the house entries and exits. It's hard to manage if there are a lot of houses, but it's the best I can do at my current skill level...
    The only difference is that I stored the results from FindObjectsOfType() in a singleton since access to the house is very frequent.
    Thanks again for your help!
  • Keep in mind that scene changes destroy those game objects, unless they're marked as DontDestroyOnLoad.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.