 |
|
|
|
|
 |
|
|
Guest
|
Flight simulation HELP!! -
08-13-2010, 03:24 PM
I'm working on a flight simulation project where the plane will crash on the ground when it hits or contacts the barn house of the windmill. I've tried to follow the other codes from other flight simulations on here, but I couldn't make the plane to crash. I'm attaching the file on here. I've been working on this for two days now and I'm a little "punched-drunk".
When I try to put an If/Else statement:
If [plane] distance above [ground] < 0
call world.collision method
Else
Do nothing
The world.collision method works. However, since I have my plane flying in a loop with the engine sound, even after the crash, the sound still keeps going.
So, I thought that since this has worked with the "ground", I thought it would work on the barn and the windmill as well. Well, it didn't. I changed the "If/else" statement to:
If [plane] distance to [barn] < 0
The plane just went past through the building.
Here are my questions:
- What did I do wrong when I changed the "If/else" statement? How come it worked when the target was the ground and not the barn or the windmill?
- How can I make the infinite loop (where I have the code for the engine sound and plane flying) stop after the crash?
I would appreciate any help. Thank you!
thank you!!
Last edited by lstricland; 08-13-2010 at 04:04 PM.
|
|
|
|
|
Senior Member
Status: Offline
Posts: 976
Join Date: Sep 2009
Location: United States
|

08-13-2010, 04:20 PM
The reason it goes right through the barn is because you made it "Distance to < 0". Think about it logically now, when will the planes distance to the barn every be a negative number? It is literally impossible. When you are even an inch away from the barn, the distance to the barn will still be 1 inch. Even if you managed to fly perfectly into the barn, crossing the axis of the plane with the axis of the barn, the distance to the barn will still be 0, and when you pass by it, the distance will just go back up again but not into the negatives, your collision method will only work when the distance is less than 0, so it is impossible.
What you need to do is the function "object is within distance of object" for the barn, so that when the plane is within a certain distance of the barn, it will crash.
Check out my best projects so far and please comment:
Tic-Tac-Toe 2.0 ................... http://www.alice.org/community/showthread.php?t=3548
Alice Paint ........................... http://www.alice.org/community/showthread.php?p=23408
Real-Time Clock .................. http://www.alice.org/community/showthread.php?p=12725
Maze Game ......................... http://www.alice.org/community/showthread.php?t=4301
|
|
|
|
|
Senior Member
Status: Offline
Posts: 852
Join Date: May 2010
|

08-13-2010, 04:31 PM
Quote:
How can I make the infinite loop (where I have the code for the engine sound and plane flying) stop after the crash?
|
Make a boolean variable called 'crash.'
In your collision method,
Quote:
If [plane] distance above [ground] < 0
call world.collision method
Else
Do nothing
|
Add 'crash set value to true' in the 'if' part as well.
Basically,
If [plane] distance above [ground] < 0
[crash] set value to [true]
world.collision method
Else
Do nothing
Next, get rid of the infinite loop.
Instead, use a while with the [crash] is [true] inside, with your flying method inside the while statement.
So,
While [crash] is [true]
world.flyandsound
When [crash] becomes true, then you won't hear the sound nor be able to fly.
|
|
|
|
|
Guest
|
Thanks a bunch! -
08-13-2010, 04:41 PM
Thank you so much...I'll go ahead and try this one. I'll be back (hehe!).
Quote:
Originally Posted by debussybunny563
Make a boolean variable called 'crash.'
In your collision method,
Add 'crash set value to true' in the 'if' part as well.
Basically,
If [plane] distance above [ground] < 0
[crash] set value to [true]
world.collision method
Else
Do nothing
Next, get rid of the infinite loop.
Instead, use a while with the [crash] is [true] inside, with your flying method inside the while statement.
So,
While [crash] is [true]
world.flyandsound
When [crash] becomes true, then you won't hear the sound nor be able to fly.
|
|
|
|
|
|
Senior Member
Status: Offline
Posts: 852
Join Date: May 2010
|

08-13-2010, 04:44 PM
Let us know if you have problems with that.
BTW, if you could post the world (when you post, click 'manage attachments,' and upload your file), I could try to fix it.
EDIT: Oops, didn't see that you had posted it. I'll take a look at it.
Good luck!
Last edited by debussybunny563; 08-13-2010 at 05:07 PM.
|
|
|
|
|
Senior Member
Status: Offline
Posts: 976
Join Date: Sep 2009
Location: United States
|

08-13-2010, 04:56 PM
Just telling you now, a While statement is basically the same exact thing as a loop, it just tells the loop when the stop. Because the crash is only going to happen once per flight however, it is a good idea to use the While statement, but you can do the same thing with a loop if you know how. Also the boolean is a good idea. You can use that to stop the sounds once the plane crashes by putting the sounds out of an infinite loop and into a while statement as well.
Check out my best projects so far and please comment:
Tic-Tac-Toe 2.0 ................... http://www.alice.org/community/showthread.php?t=3548
Alice Paint ........................... http://www.alice.org/community/showthread.php?p=23408
Real-Time Clock .................. http://www.alice.org/community/showthread.php?p=12725
Maze Game ......................... http://www.alice.org/community/showthread.php?t=4301
|
|
|
|
|
Guest
|

08-13-2010, 05:33 PM
I just tried to put it in a "While" loop, but it still didn't crash on the barn?
I actually need to make it crash to the barn or the windmill, not to the ground. I am attaching the updated version of the Alice file that I'm working on.
I appreciate any help you can give me. Thank you so much!
Quote:
Originally Posted by debussybunny563
Let us know if you have problems with that.
BTW, if you could post the world (when you post, click 'manage attachments,' and upload your file), I could try to fix it.
EDIT: Oops, didn't see that you had posted it. I'll take a look at it.
Good luck!
|
|
|
|
|
|
Guest
|
I just changed it...still didn't work. -
08-13-2010, 04:38 PM
 Thank you for the quick response. This project is due midnight on Sunday and I still have other worlds to finish. This is the one that's really giving me a hard time.
I've changed the If statement to "plane is within 1 meter of barn", but the collision method was not executed. I tried to do the "plane distance above ground < 0", it executed the collision method. I'm not really sure what to do.
Also, even with the collision to the ground, the engine sound is still playing and the airplane continues to "fly" under ground???
Thank you again!
|
|
|
|
|
Guest
|

05-15-2011, 02:01 PM
Quote:
Originally Posted by lstricland
I'm working on a flight simulation project where the plane will crash on the ground when it hits or contacts the barn house of the windmill. I've tried to follow the other codes from other flight simulations on here, but I couldn't make the plane to crash. I'm attaching the file on here. I've been working on this for two days now and I'm a little "punched-drunk".
When I try to put an If/Else statement:
If [plane] distance above [ground] < 0
call world.collision method
Else
Do nothing
The world.collision method works. However, since I have my plane flying in a loop with the engine sound, even after the crash, the sound still keeps going.
So, I thought that since this has worked with the "ground", I thought it would work on the barn and the windmill as well. Well, it didn't. I changed the "If/else" statement to:
If [plane] distance to [barn] < 0
The plane just went past through the building.
Here are my questions:
- What did I do wrong when I changed the "If/else" statement? How come it worked when the target was the ground and not the barn or the windmill?
- How can I make the infinite loop (where I have the code for the engine sound and plane flying) stop after the crash?
I would appreciate any help. Thank you!
thank you!!
|
try and you an if/else statement on a sound object if plane<0 distance add the sound as an argument similar to opacity when the shark eats a fish yet with sound Im trying to figure out assigning keys to fly darn plane
|
|
|
Thread Tools |
|
Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Copyright ©2023, Carnegie Mellon University

Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.
|
 |