Sorry, we don't support your browser.  Install a modern browser
This post is closed.

onObjectEnterScriptingZone and onObjectLeaveScriptingZone get called too often#531

D

Using the following code:

function onObjectEnterScriptingZone(zone, object)
  if object == self and zone == tableZone then
    print("Enter")
  end
end

function onObjectLeaveScriptingZone(zone, object)
  if object == self and zone == tableZone then
    print("Leave")
  end
end

When moving the object into a scripting zone “Enter” gets printed as expected. However when the player is dropping the item in the zone both functions get called again, as soon as the object is resting. The same behaviour applies to objects being moved out of the zone.
Additionally both functions get called when a player picks up the object in the zone without moving it out of the scripting zone.

Edit: It seems like this is only an issue with semi-locked physics. Copy and pasting an object inside a scripting zone via CTRL-C and CTRL-V calls both events additionally to the expected onObjectEnterScriptingZone event. This behaviour also occurs with full physics and doesn’t seem consistent. When this problem occurs the corresponding event doesn’t get called when the object actually leaves or enters the scripting zone.

Example:
Copying and then pasting an object inside the scripting zone with the code above prints:

Enter
Leave
Enter

If the player then moves the pasted object out of the scripting zone and back into it nothing gets printed.

3 years ago

I just tested and verified this.

The bug occurs whether the two scripts are on an object or in Global (with suitably changes)

3 years ago
1