Alice Community  

Go Back   Alice Community > Alice 3 > How Do I?

Reply
 
Thread Tools Display Modes
Stop MoveForward and rotate by angle
Old
Rosky
Junior Member
 
Status: Offline
Posts: 1
Join Date: May 2021
Post Stop MoveForward and rotate by angle - 05-25-2021, 03:25 AM

Summary of what i can't find how to do:

1. StopMovingForward with CollisionDetection
2. RotateBy random angle
3. Bounce back

The project i want to do:

Want to make 5 meteorites with random sizes and random rotation fall to the ground. This means that the distance to collision with 'Ground' is unknown and the moveforward distance i have to set must be big.
When any falling meteorite hits the ground should stop moving and bounce back (preferably but not necessarly in a sine wave).
Colision detection works but how do i stop the meteorite MoveForward from going trough the 'Ground'? After stopping i want to change direction (rotate it) and move it away from ground.

Stoping it should be something simple but i don't seem to be able to find out how.
Thank You.
   
Reply With Quote
Meteorite collision with ground
Old
djslater107
Administrator
 
Status: Offline
Posts: 190
Join Date: Jan 2007
Default Meteorite collision with ground - 05-25-2021, 10:11 AM

Without know the details of how you are implementing the meteorite motion, I have attached a very simple program in which a boulder "falls" to the moon surface, and when the collision happens, a changeDirection method is called that reorients the boulder to a new, random, direction.

In my program, my boulder would always be moving in a separate procedure, the collision detection just changes the direction it is moving.

To make the boulder stay on the ground, I created a Boolean variable for the Boulder class, canBounce and initialized into true. In myFirstMethod, my while loop checks this variable to see if it can continue moving or not. In my CollisionDetector, I Set this variable to false to stop the while loop.

(Also in the CollisionDetector I enabled / disabled the changeDirection procedure or the meeting the Boolean variable to false so you could see either option.)

I hope this helps.
Attached Files
File Type: a3p changeDirection.a3p (118.1 KB, 2 views)


Don Slater
Alice Team
Carnegie Mellon University
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



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