Bug Issue: Collisions don't work if last created actor was not immediately created.


Pages: 1

LIBERADO

  • Expert Stencyler
  • *
September 22, 2015, 05:18:19 am
Collisions are not working in my game, and I have found a major bug.

I have checked all collision Events, and they don't work when "Last Created Actor" is selected in their first dropdown menu and the last created actor has not been inmediately created at the game start.
The following is a clear example...

This works:


But this does NOT work:


I think this is a important bug, and it is hampering my work because due to this bug I can not detect collisions of actors that are being continuosly created at different times during the gameplay.

Please, fix it.


oripessach

  • Subscriber - Stencyl Studio
  • *
September 22, 2015, 08:00:13 am
This doesn't look like a bug. In fact, it doesn't look like it should work at all.

Why? Because when the event is defined, Last Created Actor won't return what you think it will, because the new actor hasn't been created yet.

Stencyl handles collision events by calling addCollisionListener() when creating the actor (in the init() method) and passing the value returned from getLastCreatedActor() as the first argument. This is done once. If getLastCreatedActor() returns the wrong value, that's a problem.

Check out the Preview Code tab in the behavior designer - the problem will be pretty obvious.


Jon

  • Chief Stencyler
  • *
September 22, 2015, 10:22:49 am
When + "last created actor" doesn't make a whole lot of sense and shouldn't even be allowed in an event since there's no context for what the "last created actor" is at that point. Set that actor instance to a variable and use that instead.

The fact that it works in case one is a coincidence but should not be counted on.
  • Status changed from New to Closed
  • Tags added: not-a-bug
« Last Edit: September 22, 2015, 10:23:43 am by Jon »


Bhoopalan

  • Level 5 Stencyler
September 22, 2015, 01:47:19 pm
Hey Liberado,

You've helped us a lot to learn Stencyl. May be it's time to payback. I believe I have a workaround for this situation.

1. Create the actor when the scene is created.
2. Set that actor instance to a variable
3. Create it outside the scene and make it always active.
4. When you need to show it in screen at x:288 & y:192, use the 'slide' block at 0 seconds. It'll create an effect as if the actor is created and not slid.

Of course, the effect is temporary as it may not suit all type of needs.


Bhoopalan

  • Level 5 Stencyler
September 22, 2015, 01:49:56 pm
When + "last created actor" doesn't make a whole lot of sense and shouldn't even be allowed in an event since there's no context for what the "last created actor" is at that point. Set that actor instance to a variable and use that instead.

The fact that it works in case one is a coincidence but should not be counted on.

Hi Jon,

This won't work as well. If the actor is not assigned immediately when the scene is created, it will still not detect the collision. I submitted a detailed report. Please check my bug report I submitted today.


LIBERADO

  • Expert Stencyler
  • *
September 22, 2015, 01:56:26 pm
Ok.


Jon

  • Chief Stencyler
  • *
September 22, 2015, 01:59:39 pm
Hi Jon,

This won't work as well. If the actor is not assigned immediately when the scene is created, it will still not detect the collision. I submitted a detailed report. Please check my bug report I submitted today.

You might be right about that. Detecting events against actor attributes may not work at all, for the same reason that last-created-actor won't work, because at the time that the event is created, that attribute hasn't been set.

So if you want to do this, you'd need to attach the event directly to the actor - don't use last created actor and do not set an attribute.
« Last Edit: September 22, 2015, 02:00:34 pm by Jon »


Bhoopalan

  • Level 5 Stencyler
September 22, 2015, 02:11:43 pm
Hi Jon,

This won't work as well. If the actor is not assigned immediately when the scene is created, it will still not detect the collision. I submitted a detailed report. Please check my bug report I submitted today.

You might be right about that. Detecting events against actor attributes may not work at all, for the same reason that last-created-actor won't work, because at the time that the event is created, that attribute hasn't been set.

So if you want to do this, you'd need to attach the event directly to the actor - don't use last created actor and do not set an attribute.

That's a good suggestion. However, the problem would be with the attributes in that case. Attributes created in scene won't be identified inside the actor's event. We might be forced to use game attributes then. However, it's suggested not to use many game attributes for smoother experience.


letmethink

  • Master Stencyler
  • *
September 22, 2015, 02:31:19 pm
Perhaps when an attribute is set (or changed), the relevant listeners for it could be updated?


LIBERADO

  • Expert Stencyler
  • *
September 22, 2015, 02:52:05 pm
Perhaps when an attribute is set (or changed), the relevant listeners for it could be updated?
I also would like to know the answer to this question.


Jon

  • Chief Stencyler
  • *
September 22, 2015, 09:25:19 pm
That would require an attribute to maintain a list of listeners. Most attributes are plain old class-level variables, so this would be a pretty big change.


Pages: 1

Details

  • Reported
    September 22, 2015, 05:18:19 am
  • Updated
    September 22, 2015, 09:25:19 pm

  • View Status
    Public
  • Type
    Bug
  • Status
    Closed
  • Priority
    Normal
  • Version
    Stencyl 3.3
  • Fixed in
    (none)
  • Assigned to
    (none)
  • Category
    Compiling/Testing Games

Tags