Alice Community  

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

View Poll Results: Use prebuild walking or build your own? Which do you prefer?
I like making my own 5 71.43%
Really like the prebuild walking methods 2 28.57%
Multiple Choice Poll. Voters: 7. You may not vote on this poll

Reply
 
Thread Tools Display Modes
Character Walking causes Alice to Crash ?
Old
draudia
Guest
 
Status:
Posts: n/a
Question Character Walking causes Alice to Crash ? - 02-19-2010, 12:14 PM

Hi,

We are trying to figure out how to make our Alice Characters walk by being controlled by the Keyboard - While key is pressed Event.

Everybody in class is having the same issue.

When you run the program and press the key, the character walks fine, but when you release the key - Alice Crashes.

Are we doing this correctly or is there a better way to control the prebuild walk methods via keyboard interactions?

Thanks for your help.
Attached Files
File Type: a2w walking_problem.a2w (522.9 KB, 11 views)
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 02-19-2010, 12:43 PM

That's an issue experienced by a choice few, apparently, as I personally experience it, but others (Dameria, if I'm not mistaken) don't.

The problem comes from interrupting movements inside the "While a key is pressed" event. For some reason, inside that event it triggers an error. If you use a middleman, like a boolean variable that's set to true when the key is pressed, then false when it's released, it should work.


(')>
   
Reply With Quote
Creating Fix
Old
draudia
Guest
 
Status:
Posts: n/a
Default Creating Fix - 02-19-2010, 09:24 PM

Yes, I just replicated the problem on my home computer as well as my school computers. Strange bug.

So let me get this right, are you suggesting to create a boolean variable instead of using the "Create Event" when world starts - When up key is pressed or adding it somehow to the start of the program? Sorry, not sure I quite understand.

thanks
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 976
Join Date: Sep 2009
Location: United States
Default 02-19-2010, 09:35 PM

Yea I don't get this error when I run programs using the event, however what would happen on mine is that the character would just stop walking exactly where he is midstep without putting his foot down, and when you press it again it would just carry on from there.


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
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 02-19-2010, 11:22 PM

Here is what I'm suggesting.

Keep your movement events (the While the key is pressed events can stay), but instead of having movement commands in the Begin, During, and End parts of the event, make a boolean variable set itself to true in Begin and to false in End. Then, use a method of your choice (I prefer using the event "When something becomes true", which can be made by right-click-changing a "While something is true" event, to call a method which contains a while loop that executes the desired motion) to connect the boolean variable's being true to the character's motion. Same effect, no glitch (at least not for me).


(')>
   
Reply With Quote
Old
dragnet
Member
 
Status: Offline
Posts: 38
Join Date: Jan 2010
Default 03-19-2010, 02:12 PM

Thanks for this 'bug' report. Helped me stop my crashing woes. I can confirm this fix stops Alice from crashing.
   
Reply With Quote
Old
davidghemer
Member
 
Status: Offline
Posts: 38
Join Date: Nov 2011
Default 11-03-2011, 11:12 PM

I was also having this problem with the built-in methods that come with the person builder classes.
Here's a link to a tutorial that describes how to program characters using the built-in walking animations to walk while a key is pressed.

http://programminginalice.wordpress....-in-alice-2-2/

It pretty much uses the method suggested by x2495iiii, using a finite state machine to control the walking animation, and changing the state of the FSM at the beginning and end of the while key is pressed event.
   
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 ©2020, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.