Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Moving form one point to another
Old
Tsuyoshi
Guest
 
Status:
Posts: n/a
Default Moving form one point to another - 08-31-2008, 12:08 AM

Hi,

I am stuck on this problem and would appreciate any help given here.

I had created 3 objects: 1 ghost and 2 tombstone.

I would like the ghost to move from one tombstone to another and return to the previous tombstone repeatedly. Sort of like ghost patrolling from one point to another repeatedly.

However I could only made the ghost to travel to 1 tombstone and when it return it does not stop, instead it go right through.

Anyone kindly help please? Thanks.

I attached my code for viewing here. Thanks
Attached Files
File Type: a2w ghost.a2w (791.5 KB, 58 views)
   
Reply With Quote
I think this is the reason
Old
Digimath
Guest
 
Status:
Posts: n/a
Default I think this is the reason - 08-31-2008, 07:07 AM

After the ghost turns and once is again two meters away from tombstone2 the program goes back to just doing the true part of your if statement (which is just a move forward statement).
   
Reply With Quote
Tried many others options!!
Old
Tsuyoshi
Guest
 
Status:
Posts: n/a
Default Tried many others options!! - 08-31-2008, 12:57 PM

Hi,

Thanks for replying but I had also tried various distance in front or others distance methods to no avil.

Would appreciate any help given! thanks.
   
Reply With Quote
I'd add some logic to know where the ghost was headed
Old
Digimath
Guest
 
Status:
Posts: n/a
Default I'd add some logic to know where the ghost was headed - 08-31-2008, 03:11 PM

There’s always multiple ways to program something. In this case I’d might use a Boolean variable to keep track of which tombstone the ghost was facing.



Code:
Set "Is ghost going toward tombstone 1" to false.

While …

  If  ("Is ghost going toward tombstone 1")  then
    if  (ghost is a least 2 meters from tombstone1)  then
        ghost move forward 0.5 meters
    else
       ghost turn to face tombstone2
       ghost move forward 0.5 meters
       set "Is ghost going toward tombstone 1" to false.

  Else
    if   (ghost is a least 2 meters from tombstone2)  then
     ghost move forward 0.5 meters
   else
     ghost turn to face tombstone1
     ghost move forward 0.5 meters
     set "Is ghost going toward tombstone 1" to true

(But there are probably better ways to do this.)
   
Reply With Quote
Old
Tsuyoshi
Guest
 
Status:
Posts: n/a
Default 08-31-2008, 09:23 PM

Hi,
I tried your method but it seem that the ghost will stop moving after it turn to face tombstone 2. this is properly due to the boolean valur turning to false.

Is it possible to help try amend the code to achieve what I needed.

I am so lost.

thanks.


Quote:
Originally Posted by Digimath View Post
There’s always multiple ways to program something. In this case I’d might use a Boolean variable to keep track of which tombstone the ghost was facing.



Code:
Set "Is ghost going toward tombstone 1" to false.

While …

  If  ("Is ghost going toward tombstone 1")  then
    if  (ghost is a least 2 meters from tombstone1)  then
        ghost move forward 0.5 meters
    else
       ghost turn to face tombstone2
       ghost move forward 0.5 meters
       set "Is ghost going toward tombstone 1" to false.

  Else
    if   (ghost is a least 2 meters from tombstone2)  then
     ghost move forward 0.5 meters
   else
     ghost turn to face tombstone1
     ghost move forward 0.5 meters
     set "Is ghost going toward tombstone 1" to true

(But there are probably better ways to do this.)
   
Reply With Quote
Ghost now patrolling
Old
Digimath
Guest
 
Status:
Posts: n/a
Default Ghost now patrolling - 08-31-2008, 10:21 PM

I modified your program with some changes that now make the ghost patrol between the two tombstones
Attached Files
File Type: a2w ghost patroling.a2w (794.6 KB, 57 views)
   
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 ©2023, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.