Results 1 to 3 of 3

Thread: function onCollisionEnter() triggers a zillion times?

  1. #1

    function onCollisionEnter() triggers a zillion times?

    I'm looking at some simple code to do something when a object is dropped on the table, but having a strange problem right at the start. Basically using this simple code below which just dose a print out when the object is dropped on the table

    Code:
    function onCollisionEnter()
    print("Dropped")
    end

    As you can see just dropping it activates it like 8 times.


    If I drop one of the enemy tokens on the various parts.. it activates twice, each time.

    So, is that behaving correctly?

    Is there a way to only make it trigger once?
    Is there a way to only trigger when it hits the table and NOT when other things hit it?

    Also... is there anyway to tell if an object is at rest?

    Like if I used a scripted zone that tested when things entered it.. this would basically be the same code.. can you make it so it ignores everything unless it comes to a rest inside the zone?

  2. #2
    Join Date
    May 2016
    Posts
    1,072
    Its behaving correctly.

    object.resting will return true if it isn't resting, false if it is not. You can also set object.resting = true.

    One way that might work is having the first onCollisionEnter make object.resting = true. That might do it.

    If not, you could make a toggleable variable. Psudocode that would go in oncollisionenter
    Code:
    if toggleVariable = false then
        toggleVariable = true
        --start a timer which, when it ends, will make toggleVariable = false
        --The code you only want to have run once
    end

  3. #3
    Thanks stump... this seams to be working.

Similar Threads

  1. onCollisionEnter not triggering on multiple items?
    By Jabrwock in forum Scripting Bug Reports
    Replies: 1
    Last Post: 06-13-2017, 01:50 PM
  2. Replies: 3
    Last Post: 12-03-2016, 06:35 AM
  3. Replies: 5
    Last Post: 08-14-2016, 09:20 PM
  4. [ADDED] [v8.0] Triggers and Motor Mechanics
    By Kazkade in forum Suggestions
    Replies: 1
    Last Post: 03-29-2016, 06:00 PM
  5. Log to show mod load times
    By Strumiker in forum General Discussion
    Replies: 4
    Last Post: 10-10-2015, 12:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •