Alice Community  

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

Reply
 
Thread Tools Display Modes
How do I constrain an object to not sink into the ground?
Old
wpugh
Guest
 
Status:
Posts: n/a
Default How do I constrain an object to not sink into the ground? - 04-13-2008, 08:59 PM

I'm trying to create some simple tutorials with my kids.

I'm creating something where an EvilNinja chases a bunny. The ninja moves towards tha bunny, and the bunny moves away from the ninja. What happens is that since the ninja is taller than the bunny, when the bunny moves away from the ninja it starts to sink underground. The Ninja follows it, and they both move ever downwards.

Is there anyway to constrain the z positive of an object, or even to simply set the z coordinate of an object?

While I'm at it, while there is way to have an object turn to face away from something?
   
Reply With Quote
Old
DickBaldwin
Guest
 
Status:
Posts: n/a
Default 04-13-2008, 11:16 PM

Quote:
Originally Posted by wpugh View Post
I'm trying to create some simple tutorials with my kids.

I'm creating something where an EvilNinja chases a bunny. The ninja moves towards tha bunny, and the bunny moves away from the ninja. What happens is that since the ninja is taller than the bunny, when the bunny moves away from the ninja it starts to sink underground. The Ninja follows it, and they both move ever downwards.

Is there anyway to constrain the z positive of an object, or even to simply set the z coordinate of an object?

While I'm at it, while there is way to have an object turn to face away from something?
The simple answer is yes, yes, and yes

Rather than to try to provide the details in this short space, I am simply going to refer you to http://www.dickbaldwin.com/tocalice.htm where I believe you will find the answers to your questions.

Dick Baldwin
Free Alice tutorials: http://www.dickbaldwin.com/tocalice.htm
Free programming tutorials: http://www.dickbaldwin.com/toc.htm

P.S.
Loop 5 times
Do together
evilNinja move amount = 2 meters toward target = bunny
bunny move amount = 2 meters away from target = evilNinja

Last edited by DickBaldwin; 04-13-2008 at 11:38 PM.
   
Reply With Quote
Re: How do I constrain an object not to sink into the ground
Old
hgs
Guest
 
Status:
Posts: n/a
Default Re: How do I constrain an object not to sink into the ground - 04-14-2008, 09:34 AM

Dick, I don't think your answer addresses the question. I think you have just reproduced what wpugh is already doing. I have had this problem of characters walking into the ground before and as yet found no way around it. Google searches of your site don't throw up results that look like they address this issue. Maybe you can post a more specific link? I haven't run your code, but that sort of program has always resulted in unwanted changes of vertical position, in my experience.

Alice3 developers: If you are reading this, then move_horizontally_towards and move_vertically_towards might be useful methods to consider, or being able to specify the principle plane in which to move xy, xz, yz, (front, right, up for x, y, z?) with the as_seen_by parameter to adjust angles more finely, might be a good solution to this. Maybe if Alice >= 2.2 has all animate object with a walk_towards method, this will be less needed, provided walking is constrained to be horizontal. Slight rotations of the characters may still upset this, of course.

Off the top of my head, I can't think of a way to turn a character to face away, without turning to face the target.
   
Reply With Quote
Quick thoughts
Old
DrJim
Guest
 
Status:
Posts: n/a
Default Quick thoughts - 04-14-2008, 11:28 AM

For staying above ground - just run the method inside a while statement with the test "while object is above ground." If you need to recover from going below ground, you can do that with a separate while "object's distance above ground is <=0" method.

As far as tracking along a plane - the specific problem - the only way I know to do that easily is place a "not seen" object located at the target but at the same height above ground as the tracking object (bunny) and then make the dummy object the vehicle for the target and have it act as the effective target location for your code.

For facing away, do the turn to face and then turn 1/2 revolution - but do both with zero second durations.
   
Reply With Quote
Old
DickBaldwin
Guest
 
Status:
Posts: n/a
Default 04-14-2008, 01:02 PM

Quote:
Originally Posted by hgs View Post
I haven't run your code, but that sort of program has always resulted in unwanted changes of vertical position, in my experience.
Maybe I was asleep at the mouse, but the code that I provided appeared to run fine for me and I didn't see anything sinking into the ground. I will run it again just to make certain. The code is very short, so run it and tell me what you get. Be sure to use a bunny and an evil ninja. I believe that the key is the location of the center points on the two objects. In this case, the center point of both objects appears to be on the ground between their feet.

Thanks for the input.

Dick Baldwin
Free Alice tutorials: http://www.dickbaldwin.com/tocalice.htm
Free programming tutorials: http://www.dickbaldwin.com/toc.htm
   
Reply With Quote
Object Center Points
Old
DrJim
Guest
 
Status:
Posts: n/a
Default Object Center Points - 04-14-2008, 01:11 PM

One of the real strengths of Alice is it's extensive library of objects which was developed by many contributors. Unfortunately, there was apparently no initial standard - and each of the contributors had their own idea as to where the "center" of an object should be - which can lead to interesting results. Having the center of an object end up in (very) strange locations is also a hazzard of importing your own objects.

One suggestion if you are having problems is to view the objects with their axis showing.
   
Reply With Quote
My solution to the quicksand problem
Old
DickBaldwin
Guest
 
Status:
Posts: n/a
Default My solution to the quicksand problem - 04-14-2008, 02:27 PM

Quote:
Originally Posted by hgs View Post
Dick, I don't think your answer addresses the question. I think you have just reproduced what wpugh is already doing. I have had this problem of characters walking into the ground before and as yet found no way around it. Google searches of your site don't throw up results that look like they address this issue. Maybe you can post a more specific link? I haven't run your code, but that sort of program has always resulted in unwanted changes of vertical position, in my experience....
I have attached my solution to the problem of the objects sinking into the ground during the chase. Please let me know if it doesn't work for you.

Properly setting the stage is critical in many Alice applications, and this is a good example of such an application.

See the following lessons on my website:

http://www.dickbaldwin.com/alice/Alice0115.htm
http://www.dickbaldwin.com/alice/Alice0120.htm

By the way, when I refer someone to my website, I don't always mean to imply that the exact answer to a specific question is provided there. Often I am simply indicating that if the person learns from the material that is provided there, they can usually answer their own questions.

Paraphrasing what a wise person once said:

Give a student a fish to eat and he will be hungry again tomorrow.
Teach him to fish and he will never be hungry.

Dick Baldwin
Free Alice tutorials: http://www.dickbaldwin.com/tocalice.htm
Free programming tutorials: http://www.dickbaldwin.com/toc.htm
Attached Files
File Type: a2w BunnyChase.a2w (900.4 KB, 144 views)
   
Reply With Quote
A more detailed explanation of the cause of the problem
Old
DickBaldwin
Guest
 
Status:
Posts: n/a
Default A more detailed explanation of the cause of the problem - 04-14-2008, 03:29 PM

Quote:
Originally Posted by DrJim View Post
One of the real strengths of Alice is it's extensive library of objects which was developed by many contributors. Unfortunately, there was apparently no initial standard - and each of the contributors had their own idea as to where the "center" of an object should be - which can lead to interesting results. Having the center of an object end up in (very) strange locations is also a hazzard of importing your own objects.

One suggestion if you are having problems is to view the objects with their axis showing.
To expand on what DrJim says above, the cause of the problem is explained in the section that begins as follows at http://www.dickbaldwin.com/alice/Ali...htm#moveToward

Begin quoted material =============================
The moveToward method

Recommended study trail: Return to the discussion of the method named moveTo.


Brief description: A method to cause an object to move a specified distance toward another object along an imaginary line that connects the center points of the two objects, without changing the orientation of either object. Also supports the asSeenBy parameter, which can complicate the behavior of the method.
=========================== End of quoted material


The methods named moveToward and moveAwayFrom behave essentially the same way with the main difference being the direction of motion. If you call either method without first assuring that the center of the two objects is at the same level relative to the ground, the line connecting the two centers will not be parallel to the ground, and the objects will either sink into the ground or fly away into the air depending on the direction of motion.

It is important that the programmer understands the behavior of a method before using that method in an Alice application. Otherwise, strange results may occur.

Unfortunately, CMU has not provided any information regarding method behavior except for their commercial textbook. You will find my description of the behavior of each of the primitive methods in Alice 2.0 at http://www.dickbaldwin.com/alice/Alice0900.htm While somewhat boring, this is probably the most important Alice material on my website. Note, however, that my interpretation of the behavior of each method is based on experimentation, and may not be correct in all cases.

If your Alice application doesn't behave according to your expectations, I strongly recommend that you consult that material and learn about the behavior of the methods that are called in your application. (When all else fails, read the instructions. It would actually be better if you learn about the behavior of each method before you use it.)

Dick Baldwin
Free Alice tutorials: http://www.dickbaldwin.com/tocalice.htm
Free programming tutorials: http://www.dickbaldwin.com/toc.htm

Last edited by DickBaldwin; 04-14-2008 at 03:31 PM. Reason: Correct grammar
   
Reply With Quote
This is it
Old
Nickto1414
Guest
 
Status:
Posts: n/a
Default This is it - 08-02-2008, 06:02 PM

Simpily
While A<=B Distance above X Left Leg

A=0
B=Ground
X=Object

You can get the A<=B in world -Functions
   
Reply With Quote
Old
debussybunny563
Senior Member
 
debussybunny563's Avatar
 
Status: Offline
Posts: 852
Join Date: May 2010
Arrow 10-01-2010, 08:35 PM

There is a relatively simple method to solve this.

1. Add a dummy object to the world. Make sure it is upright/parallel to the ground (use the method "stand up" to ensure this).

2. Ninja turn to face bunny and move forward whatever amount.

3. Dummy move to ninja duration 0 seconds.

4. Dummy turn to face bunny duration 0 seconds.

5. Bunny move forward whatever amount asSeenBy dummy.

6. Repeat steps 2-6 however many times you want it to loop.


Last edited by debussybunny563; 12-21-2012 at 12:00 AM.

|--------------------------------------------------------------------------------------------------|
|Link to weapons collection: http://www.alice.org/community/showthread.php?t=7368 |
|--------------------------------------------------------------------------------------------------|

I have been dead for quite some time now; not much hope for resurrection.
   
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 ©2019, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.