|
|
|
#1 |
|
Junior Member
Join Date: Jul 2004
Posts: 9
|
Random move...orient to path?
How do I make my MC point in the direction its moving?
This is the code
EDIT: I added [ as ] tags to your code for readability. See the forum guidelines. - jbum Last edited by jbum; 10-15-2004 at 07:36 PM. |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
|
Here's a rewrite of your code that includes rotation in the direction of movement.
I also changed the method of detecting if you've reached your destination.
Last edited by jbum; 10-15-2004 at 08:55 PM. |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Jul 2004
Posts: 9
|
well its not working?
I just visited your website...and what I would like...is something like your "bee" (It pointing the way its moving). Im trying to make a moviclip, with a butterfly flying randomly over screen. |
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
|
A couple things:
1) I forgot to mention that with this code, your 'normal' movieclip (with rotation at zero) should be pointing to the right. If by 'not working' you mean that your movieclip was pointing 90 degrees to the left of where it should be, then that was the problem. If you can't fix the movieclip to point to the right, you can add a constant to the rotation to compensate for this: this._rotation = ar*180/Math.PI + 90; If by 'not working' you mean something else (such as an error message), please be clear about how it's not working, do I can help you fix it. 2) There was a syntax error in my code which I have since fixed (an extra paren). Finally, I'm guessing you want your movieclip to turn smoothly instead of flipping around quickly, as it is now. This is a bit more complicated and I'll post it shortly. Last edited by jbum; 10-15-2004 at 08:57 PM. |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
|
Here's code which smoothly turns the object. Again, the 'normal' object should be pointed the right.
|
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Jul 2004
Posts: 9
|
Okay the first script...Mc pointing wrong direction...like you said!
Im now trying with the new code....and it is looking better. It still do a little movement pointing wrong, but it looks better....thanks mate! appreciated! |
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Jan 2006
Posts: 1
|
I would like to do something similar to this, having a small movie clip randomly moving about the workspace, tho i'm new to using actionscript and am unsure if the code given here is all i need or not? Also unsure whether the actionscript goes in the first frame keyframe or the movieclip or somewhere entirely different? Thanks for any help with this
|
|
|
|
![]() |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|