Uniquely pick only one each of three objects in sub event

0 favourites
  • 7 posts
From the Asset Store
Very simple code without excess options (15 events for server and 11 events for client)
  • I have a strange issue with multiple sets of objects interacting with each other.

    I have two objects, let's call them ObjA and ObjB, which are part of a pair. ObjA keeps a reference to ObjB's UID. There are multiple pairs of ObjA and ObjB scattered throughout the layout.

    I also have several of another object, let's call it Marker. A pair of ObjA/B are supposed to perform specific actions together when ObjA collides with Marker. The trouble is, it seems that EVERY pair of ObjA/B will perform this action when one touches a Marker. If I delete all but one pair, the remaining one behaves as expected.

    This is my code (approximately):

    • On ObjA collision with Marker + Pick instance of ObjB by UID stored in ObjA:
    • - If Marker.variable = 1: ObjA do thing 1; ObjB do thing 2
    • - If Marker.variable = 2: ObjA do thing 3; ObjB do thing 4

    Expected: One ObjA touches a Marker and does its thing 1, while its attached ObjB does its own matching thing 2.

    Result: One ObjA touches a Marker and EVERY ObjA does thing 1, and EVERY ObjB does thing 2.

    How do I ensure that only the ObjA and ObjB uniquely picked at the top are the objects selected in sub events?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Create an instance variable (boolean) for ObjA called 'hit_marker'. When an ObjA hit a marker, set 'hit_marker' to true.

    Now you can pick ObjA that is 'hit_marker' to do certain actions.

    In your stated approach, no ObjA being clearly filtered because the reference is the Marker not ObjA UID or IID.

  • [quote:1n1736en]- On ObjA collision with Marker + Pick instance of ObjB by UID stored in ObjA:

    • - If Marker.variable = 1: ObjA do thing 1; ObjB do thing 2
    • - If Marker.variable = 2: ObjA do thing 3; ObjB do thing 4

    As typed it should act exactly like your expected result. If it doesn't there must be some other events effecting it.

    Can you show an image of your event or maybe a capx.

    Edit:

    alextro

    Doesn't the on collision event pick both the ObjA and Marker? I guess I'd have to test it but I haven't had to do something like that as I recall.

  • R0J0hound

    Ah you are right... sub-event. I didn't see the indentation.

    However In my experience it always better to lock a state by using boolean to make something obvious and easy to trace.

    MoscowModder

    Try to add 'for each' ObjA to force a system to recognize the condition.

  • I don't see how a for each condition would help - I only want it to happen to one pair of the objects.

    Here's a screenshot:

    Claw = ObjA; Claw_Top = ObjB; CutscenePoint = Marker

  • Nothing looks out of the ordinary, it should work. I'm guessing the event isn't a sub-event of something. I'd still say that something else is going on like some other event causing all the claws to collide with the cutscenePoint or something. Of course that's just speculation.

    I guess the next step would be the capx or a simplified version of it with the same issue. That way we have something to work with and find the cause.

  • Turns out you were on the right track, R0J0 - the very next event after the screenshot did something similar but picked Claw_Top where UID equals Claw.ClawTopUID. I swapped that out for a pick by unique ID, and the problem was solved. Thanks for the tips, people!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)