Alice Community

Alice Community (
-   How do I...? (
-   -   Variable & Collision Help (

Lasureth 09-17-2008 09:01 PM

Variable & Collision Help
1 Attachment(s)
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.:mad:

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.:confused:

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.:p

Thanks for helping!:D

DrJim 09-18-2008 12:59 PM

1 Attachment(s)
[B][I]Re the variable problem[/I][/B] - 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.

[B][I]Re the multiple object/list question[/I][/B] - 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. :confused: Once more, it's obvious Alice 2.0 and collision detection really isn't a great combination. :(

Lasureth 09-18-2008 02:45 PM

Thank You
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 [I]C++ for dummies[/I] 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. ^.^

DrJim 09-18-2008 05:31 PM

[QUOTE=Lasureth;6768] I will remember that even Alice has scope.

Also please remember that the definition of "scope" in Alice 2.0 is [I][B]much[/B][/I] 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. :)

DrJim 09-18-2008 06:07 PM

When vs. While Events
1 Attachment(s)
[QUOTE=Lasureth;6768] 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". [/QUOTE]

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.

All times are GMT -5. The time now is 05:56 PM.

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