alice-teacher Question about move toward

Michael L Owen MrGrog at outlook.com
Sat Feb 11 11:14:54 EST 2017


Maybe to get one or more objects to follow another?




________________________________
From: alice-teachers <alice-teachers-bounces+mrgrog=outlook.com at lists.andrew.cmu.edu> on behalf of Vanderhyde, James via alice-teachers <alice-teachers at lists.andrew.cmu.edu>
Sent: Friday, February 10, 2017 2:19 PM
To: Alice educators
Subject: Re: alice-teacher Question about move toward

Don, thanks. You explained the problem I was having exactly.

Michael, thanks. Using a hub is good work around. I also prefer using hubs over “as seen by.” After Don wrote, I thought maybe “as seen by bunny” would work, but it doesn’t unless the bunny is facing the right way. The chicken moves in a straight line, but in the direction the “as seen by” object is facing. In essence, whether you use “as seen by” or the vehicle property, the result is the same.

I’m having trouble understanding why “move to” and “move toward” don’t work the same way under the hood. They are grouped together in the methods pane, so it seems like they should have similar behavior (absolute, not relative movement). I am trying to understand how “move toward” works at all. If you use it by itself, it doesn’t matter what way the object is facing, so it gives the appearance of being independent of the facing direction, as "move to" is.

Don, you say “move toward” is relative to the object’s orientation, but it seems that in some cases it is, and in some cases it isn’t. This is why it feels like a bug to me.

Consider these three cases:

  chicken move amount = 2 meters toward target = bunny
This one moves the chicken toward the bunny, as advertised, regardless of which way either of them is facing.

  chicken move amount = 2 meters toward target = bunny asSeenBy = chicken
This one behaves exactly the same as the above case.

          chicken move amount = 2 meters toward target = bunny asSeenBy = bunny
This one is the weird case. The chicken moves in a direction that is some kind of combination of the direction the chicken is facing, the direction the bunny is facing, and the vector between them. The formula for the direction the chicken moves appears to be b-c+d, where b vector is the direction the bunny is facing, c vector is the direction the chicken is facing, and d vector is the vector from the chicken to the bunny. (Of note is if the bunny and chicken are facing the same direction, they cancel out and the chicken moves toward the bunny as expected.)

This formula explains the unexpected behavior of moving in a circle instead of moving straight while turning on an axis. The direction the chicken moves each frame is thus c’-c+d, where c is the direction the chicken is facing at the beginning of the movement, and c’ is the direction the chicken is currently facing. This makes a straight line when the chicken is not turning, but a somewhat circular shape when the chicken is turning.

This is fascinating, but I shouldn’t be spending so much time on this. I need to practice better time management. Thanks for looking into it.

James
—
James Vanderhyde
Assistant Professor, Computer Science
Program Director, Master of Applied Computer Science
Saint Xavier University
3700 W. 103rd St.
Chicago, IL 60655
773-298-3454

On Feb 10, 2017, at 12:41 PM, Michael L Owen via alice-teachers <alice-teachers at lists.andrew.cmu.edu<mailto:alice-teachers at lists.andrew.cmu.edu>> wrote:

That option could work, but in my case the chicken moved away because the ground was oriented differently. The attached world uses a different technique in which I attach a hub to an object, and make it the objects vehicle. To move the chicken, you move the hub and the rest of the chicken can do what it wants while you move. I left the hub visible, but it can be made invisible. This technique also comes in handy if you are trying to fly a plane.

Mike Owen


________________________________
From: alice-teachers <alice-teachers-bounces+mrgrog=outlook.com at lists.andrew.cmu.edu<mailto:alice-teachers-bounces+mrgrog=outlook.com at lists.andrew.cmu.edu>> on behalf of Donald Slater via alice-teachers <alice-teachers at lists.andrew.cmu.edu<mailto:alice-teachers at lists.andrew.cmu.edu>>
Sent: Friday, February 10, 2017 10:19 AM
To: Alice Teachers
Subject: Re: alice-teacher Question about move toward

Jim,
If I understand your question correctly, the student would like the chicken to spin on its own axis while moving toward the bunny, much as the same way the moon would rotate while revolving round the earth (the difference being that the chicken is not orbiting the bunny but moving toward it).

I am not sure that this is a bug, but it is certainly a side-effect of the implementation. I notice that if the chicken moves to the bunny, you do get the behavior I described above. move to  is an absolute command as that essentially Alice is setting the center point of the object to the center point of the target, and then animating that movement.

The idea of move toward, was to provide a way to have one object approach another without colliding with it. Like move, iit is a relational action, using the object's orientation to determine the animation. And in this do together, as you know, that orientation is always changing creating the spinning, just as would happen with a  move.

The solution is to use a different point of view, or orientation, to determine the path of the move toward. In the code snippet I have attached, you will see that I am using the as seen by modifier to tell the chicken to move toward the bunny as seen by the ground. (It turns out that I could also have said as seen by the bunny).

I believe that this is generating the behavior your student was looking for.

I have to tell you, you and your students always come up with interesting questions, and I enjoy wrestling with them.

Let me know if I misunderstood or if there are any other questions…

<rotating chicken.png>

All the best,
Don Slater

Alice Project
Carnegie Mellon University
Entertainment Technology Center
700 Technology Drive
Pittsburgh, PA 15219

Email: dslater at cmu.edu<mailto:dslater at cmu.edu>

I have learned this at least by my experiment: that if one advances confidently in the direction of his dreams, and endeavors to live the life he has imagined, he will meet with a success unexpected in common hours.
--- Henry David Thoreau

The true object of all human life is play. -- G.K. Chesterton


On Feb 9, 2017, at 4:22 PM, Vanderhyde, James via alice-teachers <alice-teachers at lists.andrew.cmu.edu<mailto:alice-teachers at lists.andrew.cmu.edu>> wrote:

I am using Alice 2.4.3. One of my students today produced unexpected behavior using “move toward.” Consider this code:

 Do together
          chicken turn left 1 revolution
  chicken move amount = 2 meters toward target = bunny

The chicken turns in a circle rather than turning while moving toward the bunny. I know that “move forward” combined with “turn left” will result in circular movement. But I don’t understand why “move toward” is doing it. After all, “move toward” by itself works no matter which way the chicken is facing.

Is this a bug or desired behavior? If desired, can someone explain it to me?

James
—
James Vanderhyde
Assistant Professor, Computer Science
Program Director, Master of Applied Computer Science
Saint Xavier University
3700 W. 103rd St.
Chicago, IL 60655
773-298-3454

_______________________________________________
alice-teachers mailing list
alice-teachers at lists.andrew.cmu.edu<mailto:alice-teachers at lists.andrew.cmu.edu>
https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers

<SpinningChicken.a2w>_______________________________________________
alice-teachers mailing list
alice-teachers at lists.andrew.cmu.edu<mailto:alice-teachers at lists.andrew.cmu.edu>
https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.andrew.cmu.edu/pipermail/alice-teachers/attachments/20170211/94a40035/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: FollowRabbit.a2w
Type: application/octet-stream
Size: 378085 bytes
Desc: FollowRabbit.a2w
URL: <http://lists.andrew.cmu.edu/pipermail/alice-teachers/attachments/20170211/94a40035/attachment-0001.obj>


More information about the alice-teachers mailing list