Thread: Missile code?
View Single Post
Is there a reason not to use events?
Super Moderator
Status: Offline
Posts: 250
Join Date: Dec 2012
Location: Frosno, Ca
Default Is there a reason not to use events? - 01-13-2015, 01:08 PM

Originally Posted by RavenOfCode View Post
One thing I would do is make separate methods for the different things the plane is colliding with, as Alice currently can only use the centers of the object to collide rather than the polygons that make up the object.

My suggestion is 2 basic colliding methods:
1.this would be for buildings/other planes/whatever.
Make a method called planeCollide > add ifelse statement > add loopInfinityTimes > add the function if Mig29 is within 1 meter of world > make 2 paramerters, 1 for a distance and replace the '1 meter' with this parameter, the other is an object replace 'world' with this > put the ifelse statment inside the loop > make another method > put a doTogether in it > then place planeCollide into this and us the parameters for the object you want/distance you want. (inside the ifelse statement you can put the code you want for it to reset)

2. This would be for the ground.
Make a method called collideWithGround > add ifelse statement > add loopInfinityTimes > put if else into loop > added the function 'mig29 is below ground' > then put in what you want to happen for when it crashes into the ground > then call this method in the events tab.

Hope this helps, also Alice come with a pre enstalled flight sim, in tutorials, you might want to take a look at that
It seems to me that events in Alice are more efficient and less error prone than infinite loops yet they are rarely mentioned. It there a reason not to put actions in an event rather than an infinite loop?
The types of events make it easy to check for conditions and to turn the events on and off and you don't have to figure out what infinite loop your code is stuck in when it doesn't do what you want.


Mark Henwood
Reply With Quote