Collision outside update

Hi guys ,



Is there any way to have a collision outsite the simpleupdate function ? I want to have a special event when my character is approching a wall. The collision is working only on the simpleupdate loop but if i do that the event i want to do will update everytime that i really don’t want.



For example the event could be a Nifty message , it will loop forever and that’s absolutely not i want.



Maybe i didn’t understand a concept with JME i need explanations thanks in advance ,



Regards.

No, you have to do everything in the loop.

So , how am i suppose to add an event in a update ?

Since it will loop forever and maybe have an error , is there a way to force to only 1 loop inside the simpleupdate function ?

If you stop the loop you will have zero fps. You can enqueue tasks like this to run on the OpenGL loop:

[snippet id=“10”]

I’m not sure i understand how it does force 1 loop , does your function inside the simpleupdate one ?



Can you do an example like my situation ? " A character is approaching a wall and there is a nifty message " how would you do that in the loop ?



[java]

public void simpleupdate(){



Function Collision {

If character.Position approaching Wall.position // already implemented that

Nifty Message

}

}

[/java]



How would you transform that to have only 1 instance of the nifty message ?



Thanks

No one ? :frowning:

make a boolean that will be used as a flag.



[java]

boolean onetimeNiftyEventTriggerd = false;



public void simpleupdate(){



Function Collision {

If character.Position approaching Wall.position && !onetimeNiftyEventTriggerd // already implemented that

Nifty Message

onetimeNiftyEventTriggerd = true;

}

}



[/java]

Thank you scrubalub it’s working and i understand the logic now