Alice Community  

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

Reply
 
Thread Tools Display Modes
How do I move an object to a certain position?
Old
scarlet
Guest
 
Status:
Posts: n/a
Default How do I move an object to a certain position? - 10-12-2007, 03:07 PM

I have 2 objects in my program, a bunny and a dragon

I Created a position variable "position1" And I set position1= dragon's position

Now how do I say "bunny move to position1", the "move to" method only seems to take object parameters? I would also like use position1 with functions for example, calculating bunny's distance to position1.

For now I've using invisible objects to mark positions, but I don't want to do this anymore.
   
Reply With Quote
Old
Maggie
Guest
 
Status:
Posts: n/a
Default 10-12-2007, 05:09 PM

Are you using dummies? When you click "add objects" and then "more controls" you'll see options to drop a dummy at the camera (generally for moving the camera to different positions) or you can drop a dummy at the selected object. You then get a folder of dummies in your object tree (which you'll want to rename so you can keep track of them). You can use those to move an object to a position. It's very similar to what you're doing with the invisible objects!
   
Reply With Quote
Old
Maggie
Guest
 
Status:
Posts: n/a
Default 10-12-2007, 05:13 PM

Sorry to post again... you can also set an object's point of view (from properties) to another object's point of view. This changes more than the position, though. I personally wish you could just grab the x,y,z coordinates of objects and operate on them directly. It's frustrating to have to use the Alice movement commands, which don't always do things the way you want. My students are patient enough to figure out how to make things look the way they want, but I don't have the patience myself! It feels like a huge waste of time because it's applicable to only one thing: Alice programming.
   
Reply With Quote
Old
DickBaldwin
Guest
 
Status:
Posts: n/a
Default 10-12-2007, 05:43 PM

Quote:
Originally Posted by scarlet View Post
I have 2 objects in my program, a bunny and a dragon

I Created a position variable "position1" And I set position1= dragon's position

Now how do I say "bunny move to position1", the "move to" method only seems to take object parameters? I would also like use position1 with functions for example, calculating bunny's distance to position1. ...
With the moveTo method, you can cause an object to take either of two actions:
  • Move itself through 3D space until its center point coincides with the center point of another object, specified as a required parameter, without changing the orientation of either object.
  • Move itself through 3D space until its center point coincides with a point in 3D space that is specified by three values in the form of a position vector. The new position is relative to the position of the object specified as the first required parameter. If that object is the world, the values in the vector represent absolute coordinate values. Again, this does not change the orientation of the object. Note however that there is an apparent bug in the system that limits this option to some degree.
See http://www.dickbaldwin.com/alice/Alice0900.htm#moveTo

Dick Baldwin
http://www.dickbaldwin.com/tocalice.htm
http://www.dickbaldwin.com/toc.htm
   
Reply With Quote
Old
scarlet
Guest
 
Status:
Posts: n/a
Default 10-12-2007, 10:52 PM

Quote:
Originally Posted by Maggie View Post
Sorry to post again... you can also set an object's point of view (from properties) to another object's point of view. This changes more than the position, though. I personally wish you could just grab the x,y,z coordinates of objects and operate on them directly. It's frustrating to have to use the Alice movement commands, which don't always do things the way you want. My students are patient enough to figure out how to make things look the way they want, but I don't have the patience myself! It feels like a huge waste of time because it's applicable to only one thing: Alice programming.
You can work with (x,y,z) directly! For example:

PostionA is a vector variable, Dragon is an object.

let PositionA= (3,5,7)

Dragon move to Word, Offset by= PositionA

That line of code should move the Dragon to (3,5,7)! Thanks Dick BALDWIN
   
Reply With Quote
Old
DickBaldwin
Guest
 
Status:
Posts: n/a
Default 10-12-2007, 11:22 PM

Quote:
Originally Posted by scarlet View Post
You can work with (x,y,z) directly! For example:

PostionA is a vector variable, Dragon is an object.

let PositionA= (3,5,7)

Dragon move to Word, Offset by= PositionA

That line of code should move the Dragon to (3,5,7)! Thanks Dick BALDWIN
You're welcome Glad I could help.

Dick Baldwin
http://www.dickbaldwin.com/tocalice.htm
http://www.dickbaldwin.com/toc.htm
   
Reply With Quote
Old
Maggie
Guest
 
Status:
Posts: n/a
Default 10-13-2007, 08:50 AM

Quote:
Originally Posted by scarlet View Post
You can work with (x,y,z) directly! For example:
BALDWIN
Thank you! That was really annoying me!!
   
Reply With Quote
Old
terrysara
Guest
 
Status:
Posts: n/a
Default 10-23-2007, 12:52 PM

Dick,

You posted,

" Originally Posted by scarlet View Post
You can work with (x,y,z) directly! For example:

PostionA is a vector variable, Dragon is an object.

let PositionA= (3,5,7)

Dragon move to Word, Offset by= PositionA

That line of code should move the Dragon to (3,5,7)! Thanks Dick BALDWIN"

I appreciate all the great feedback shared in this thread, but I have one burning question. If we can work with vector coordinates, how do we acquire them?

Specifically, how do we assign a vector to a variable upon and event occurring?

Suppose, I wanted to allow a user to CLICK on the screen and then an object move to that exact position. I know that a getVector function exist... but only for the world and not specifically the mouse?

Any ideas?

Thanks,
Terry
   
Reply With Quote
Old
DickBaldwin
Guest
 
Status:
Posts: n/a
Default 10-23-2007, 05:11 PM

At http://www.dickbaldwin.com/alice/Alice0900.htm#moveTo I wrote:

"Problems setting vector values
Although I was able to set the coordinate values in a position vector by passing literal constants to the set methods for the vector, I was not successful in setting those values by passing the name of a variable of type number as a parameter to the set methods. If this is a bug in Alice, it greatly reduces the usefulness of the vector option of the moveTo method."

I also wrote:

"A possible bug in Alice I found that I was able to successfully call these methods to specify the three values to be stored in the vector so long as I passed literal constant values as parameters. However, whenever I passed the name of another variable of type number as a parameter, the statement was simply ignored. Either I wasn't doing it correctly, or this is a bug in Alice.


Destroys an important connection to other programming scenarios
If it is a bug, it greatly reduces the usefulness of the vector option of the moveTo method. This is very significant problem. This option provides the capability of writing Alice 3D graphics programs in much the same way that they are written using other 3D programming languages that typically deal with position and direction vectors instead of forward, backward, up, down, etc."

I suspect that what you want to do can't be done using Alice 2.0, but I'm not certain. I hope that I am wrong.

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

Last edited by DickBaldwin; 10-23-2007 at 05:12 PM. Reason: Correct grammar errors
   
Reply With Quote
Old
DickBaldwin
Guest
 
Status:
Posts: n/a
Default 10-27-2007, 01:46 PM

Quote:
Originally Posted by scarlet View Post
I have 2 objects in my program, a bunny and a dragon

I Created a position variable "position1" And I set position1= dragon's position

Now how do I say "bunny move to position1", the "move to" method only seems to take object parameters? I would also like use position1 with functions for example, calculating bunny's distance to position1.

For now I've using invisible objects to mark positions, but I don't want to do this anymore.
See new material at http://www.dickbaldwin.com/alice/Ali..._using_vectors
Maybe that will help.

Dick Baldwin
Free Alice tutorials: http://www.dickbaldwin.com/tocalice.htm
Free programming tutorials: http://www.dickbaldwin.com/toc.htm
   
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 ©2023, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.