Alice Community  

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

Reply
 
Thread Tools Display Modes
Variable & Collision Help
Old
Lasureth
Guest
 
Status:
Posts: n/a
Arrow Variable & Collision Help - 09-17-2008, 10:01 PM

Alice 2.0
Some C++ Self taught experience
Learned Alice by fiddling with this world and C++ knowledge.

I created a method "World.Stance" that will [move a characters hand to their waist, set a weapon to vehicle the hand, and then set a second pose to hold the weapon out in front of them, and set a variable to false.] If I press the bound key to preform this action again [z] it is set to reverse the previous actions. I do all this in an "IF" statement that uses the variable as the identifier of the position its currently in. The variable is set to true to begin with and as stated earlier is set to false in the "True" part. But when I run the world the variable never changes. I have even "watch variabled" it and it never changes.

Also I stated a problem in "collition detection perfection" by rich0e0rick that I will say again here.

I understand the concept of what your talking about, I had used "proximity to" instead of "in front of", but my real question/problem is.... Can you set up your statement up as "if [object] is in front of[list/array of objects]". So that a character cannot move through multiple objects. Earlier when I tried this it made me choose an object from the list/array instead of all objects in the list/array. I was wondering if Alice allows you to do this.


Any and all help/comments will be appreciated.
I will attach my world. Look through the event manager to learn the controls of the world, I think its pretty self explanatory. You can also delete the "View Setup" method from the first "When world starts event" It will take out all of my unneeded animations and camera start positions.

Thanks for helping!
Attached Files
File Type: zip Character-Fairy.zip (3.59 MB, 75 views)

Last edited by Lasureth; 09-17-2008 at 10:14 PM. Reason: Add Version
   
Reply With Quote
Old
DrJim
Guest
 
Status:
Posts: n/a
Default 09-18-2008, 01:59 PM

Re the variable problem - The basic problem is the scope of the test variable (CharacterPeaceStance). Since you have defined it as part of the world.stance method, it gets reset to the default value (true) every time the method completes. (I think if you actually printed it out from within the method, you would see that it does change - though that change doesn’t have any real effect on the rest of the program.) The solution is to define the test variable at the world level.

A second note - I find the use of the end option in the "While a key is pressed" event very risky - since you never actually know the timing for this test. When I did move the test variable to the world, I still got rather flaky results - though the variable and position would usually change. I'd recommend moving the "End" method call to the end of the methods called by the "During" part of the event.

Re the multiple object/list question - Thought that would be easy - but actually had quite a few problems, including a couple of total crashes. The attached seems to work, though I had trouble doing the same thing with a torus. One thing to watch is to make sure that the test is always made "as seen by" the current object from the list and you actually know what direction each object is facing (i.e., what direction is "front") - the defaults seem to be rather unpredictable. I also had much more luck making each command zero second duration than I did using the "For all together" command - not at all sure why. Once more, it's obvious Alice 2.0 and collision detection really isn't a great combination.
Attached Files
File Type: a2w Multiple Object Collision.a2w (241.0 KB, 98 views)
   
Reply With Quote
Thank You
Old
Lasureth
Guest
 
Status:
Posts: n/a
Default Thank You - 09-18-2008, 03:45 PM

Thank you very much! My method works perfectly now! I didn't even think about the scope of the variable. I still have much to learn. Ive only been working with Alice for a month or so and I only have a self taught knowledge of C++ programming language Mostly using C++ for dummies xD. Thanks for the help I will remember that even Alice has scope.

Also about your second note. I only put the reset pose in because I observed that sometimes when you stopped moving (pressing aswd) that the arms or legs would be in weird positions, like the method was aborted halfway through, even though it should have gone right back to the beginning "pose". I added a reset at the end as a quick fix for that problem, just so the arms and legs were always at the "starting" position.

I have not had a chance to look at your multiple collision example yet, but that will be my next course of action, right after I post.

Thanks again! You have been a great help! If anyone else has any comments, tips, or corrections about my world feel free to post them. ^.^
   
Reply With Quote
Old
DrJim
Guest
 
Status:
Posts: n/a
Default 09-18-2008, 06:31 PM

Quote:
Originally Posted by Lasureth View Post
I will remember that even Alice has scope.
Also please remember that the definition of "scope" in Alice 2.0 is much more vague than the formal definition in a true OOP language. Hopefully Alice 3.0 will arrive on the scene in the not too distant future.
   
Reply With Quote
When vs. While Events
Old
DrJim
Guest
 
Status:
Posts: n/a
Default When vs. While Events - 09-18-2008, 07:07 PM

Quote:
Originally Posted by Lasureth View Post
I observed that sometimes when you stopped moving (pressing aswd) that the arms or legs would be in weird positions, like the method was aborted halfway through, even though it should have gone right back to the beginning "pose".
This is actually the correct response for the "while" event. I attached a brief example of the difference between the "when" event (which I prefer) and the "while" event - where the timing can be unpredictable for the release step. The subject is also covered in most of the texts, but the presentation material is typically scattered between several chapters.

For more comments and examples, do a search of the forum for walk methods. There have been several innovative approaches posted for a "walk while key is pressed" method.
Attached Files
File Type: a2w When vs While.a2w (219.9 KB, 73 views)
   
Reply With Quote
Reply

Tags
collision, variable

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 ©2017, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.