Collider 2D problem - bug? (Trigger using Playmaker)

I’m having a banal problem, and i can’t believe what’s happening. I’ve got the Gunpoint Object that is attached as a child of the player, with these settings:

When it comes in contact with Pickup in the scene


Box Collider 2D is disabled on purpose, it is turned on on runtime, read about it in the last paragraph.

An event should be triggered

Layer collision matrix is all set

Z positions are aligned (2D game, everything uses 1 for Z transform value and yes, children are on 0 local, so they’re on 1 global), i even tagged the Pickup Prefab, but still no collision is detected. I must be missing something banal, i tried all sorts of combinations of rigidbody types, IsTrigger checked or not, discrete/continuous collision detection and nothing works. Colliders on both bodies are pretty big.

As for the structure of the object carrying the Gunpoint object which should collide, it goes like this:

Player - Collider2D with non IsTrigger, Player Layer
Gunpoint - Collider2D with IsTrigger, as attached in the image, Gunpoint Layer
PulseGunLevel1 - Disabled Collider2D with IsTrigger, Pickup Layer

The PulseGunLevel1 which is a child of Gunpoint object is the same object that Gunpoint should collide with (that means there are two instances on the scene). Since they both spawn on runtime, that is the reason that i have, for testing purposes, disabled the collider on the prefab, as you may noted in the second image, so it stays disabled on the instance childed under the Gunpoint object, and i enable it manually on the pickup instance. I made so many layers to make sure nothing collides unintentionaly since there’s obviously a problem.

Trigger is Playmaker controlled (you can find the code below). It works, the code is pretty basic and it has been used with no problems on numerous occasions (though never on colliders of nested objects). Unity is 2017.0.2f.

Need to see your trigger event script to help

// (c) Copyright HutongGames, LLC 2010-2016. All rights reserved.

using System;
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
    [ActionCategory(ActionCategory.Physics2D)]
    [Tooltip("Detect 2D trigger collisions between the Owner of this FSM and other Game Objects that have RigidBody2D components.\nNOTE: The system events, TRIGGER ENTER 2D, TRIGGER STAY 2D, and TRIGGER EXIT 2D are sent automatically on collisions triggers with any object. Use this action to filter collision triggers by Tag.")]
    public class Trigger2dEvent : FsmStateAction
    {
        [Tooltip("The type of trigger event to detect.")]
        public Trigger2DType trigger;

        [UIHint(UIHint.Tag)]
        [Tooltip("Filter by Tag.")]
        public FsmString collideTag;

        [Tooltip("Event to send if the trigger event is detected.")]
        public FsmEvent sendEvent;

        [UIHint(UIHint.Variable)]
        [Tooltip("Store the GameObject that collided with the Owner of this FSM.")]
        public FsmGameObject storeCollider;

        public override void Reset()
        {
            trigger = Trigger2DType.OnTriggerEnter2D;
            collideTag = "Untagged";
            sendEvent = null;
            storeCollider = null;
        }

        public override void OnPreprocess()
        {
            switch (trigger)
            {
                case Trigger2DType.OnTriggerEnter2D:
                    Fsm.HandleTriggerEnter2D = true;
                    break;
                case Trigger2DType.OnTriggerStay2D:
                    Fsm.HandleTriggerStay2D = true;
                    break;
                case Trigger2DType.OnTriggerExit2D:
                    Fsm.HandleTriggerExit2D = true;
                    break;
            }
        }

        void StoreCollisionInfo(Collider2D collisionInfo)
        {
            storeCollider.Value = collisionInfo.gameObject;
        }

        public override void DoTriggerEnter2D(Collider2D other)
        {
            if (trigger == Trigger2DType.OnTriggerEnter2D)
            {
                if (other.gameObject.tag == collideTag.Value)
                {
                    StoreCollisionInfo(other);
                    Fsm.Event(sendEvent);
                }
            }
        }

        public override void DoTriggerStay2D(Collider2D other)
        {
            if (trigger == Trigger2DType.OnTriggerStay2D)
            {
                if (other.gameObject.tag == collideTag.Value)
                {
                    StoreCollisionInfo(other);
                    Fsm.Event(sendEvent);
                }
            }
        }

        public override void DoTriggerExit2D(Collider2D other)
        {
            if (trigger == Trigger2DType.OnTriggerExit2D)
            {
                if (other.gameObject.tag == collideTag.Value)
                {
                    StoreCollisionInfo(other);
                    Fsm.Event(sendEvent);
                }
            }
        }

        public override string ErrorCheck()
        {
            return ActionHelpers.CheckOwnerPhysics2dSetup(Owner);
        }
    }

}

It’s a simple Playmaker action.

Ahh right, sorry Im not familiar with playmaker. I only really create scripts by programming.

You should probably mention its made with playmaker in the topic title, as most people will assume you mean proper programming rather than playmaker.

good luck to you though! I really cant recommend how much time youll save by attempting to properly learn programming rather than using visual scripting!

Sorry, i forgot to mention, i will edit the original post now. Thanks for the advice, i’m well aware of that, but i learned a lot about programming by using Playmaker, it’s a great stepping stone for understanding how everything works. Next step will probably be flow + node canvas or nottorus, with pure coding as the final destination.

Honestly I have taught a lot of people to code in the past, and in the end you are just slowing yourself down that way.

You will get to it much faster if you just get straight to programming. It has never been easier to learn programming, trust me waiting is only allowing:

  1. The market to get more saturated as the tools get easier to use
  2. Delaying any true understanding of what your doing
  3. Not learning skills that can get you a job
  4. if playmaker dies, your screwed!

Honestly if your end destination is programming, then start learning it now! If you need extra stepping stones, that means you havent found the right teacher / resource, not that you are not ready! Trust me anyone can learn programming if they are positive, confident and find the right resources.

Im sure you wont listen as many dont, but these resources have taught others I have met to go from 0 to hero programmer in less than 3 months!

Try this:
https://unity3d.com/learn/tutorials/s/roll-ball-tutorial

then this:

Then work through these:

http://catlikecoding.com/unity/tutorials/

using this to lookup anything you dont understand: https://www.dotnetperls.com/

and https://unity3d.college/

and youll be there in no time! I cant begin to tell you how many playmaker (and other visual scripting tool) developers I have met that after years still cannot learn programming due to the bad habbits that it teaches you, also it does not teach you to “think” like a programmer, only programming does that!

@MadeFromPolygons_1

That’s all nice and dandy if i happened to be twentysomething with lots od time on my hands. Unfortunately i’m halfway to 40 with family and already have a full-time job, so i don’t need another one. I’ve been actually learning Java for two years as one of the simpler and more common languages, but to no avail, it was just Spanish for me. When i started using Playmaker, everything i learned about programming clicked into place because i was finally able to visualise everything. I haven’t neglected coding, but it’s still easier and faster for me to work this way. Maybe i’ll give a pure code a shot in the next project.

Anyway, back to the subject. One of the guys from Playmaker forums had the same issie, hired a coder to replicate the problem through code and the problem persisted. I’ll try making a small script to check it out, looks like it’s Unity based problem.

If its a unity based problem, then submit an issue report or it will just stay in there!

Also I fully appreciate what your saying, but I myself know of quite a few programmers who have only started learning to code 50+, and actually there are quite a few successful indie games made by a single 40-50+ year old who has taken a gamble and learnt a new skill.

All I’m saying is at the end of the day, your always going to have a thing in the way that stops you having the time, whether your 20 or 90. The only difference is that with automation becoming a major part of all industries, knowing programming is a fool proof way to stop future job redundancies that are bound to be coming, not affect you at all.

Either way as long as your having fun making games, that is what matters. I’m just a sucker for learning things so any chance I get to learn a new skill I snap up, because I am a nerd like that :stuck_out_tongue:

Anyway in the future if you ever are interested in doing a pure code or mainly code project, feel free to PM me and ill be happy to give you any help, advice and resources that I can!

Thanks, i really appreciate it, i’ll be sure to let you know when i need some help, and i’ll need it for sure :slight_smile:

I’ll make a small code replication of the problem i have and submit an issue :slight_smile: