my last topic didnt go well but any way
is there a way to make an object move "forward" as in not in _x because if i am on a slope my over all speed increases but my _x speed doesn't making it look odd. i have the rotation but is there a link between rotation and direction?
thanks
moving 'forward'?
(6 posts) (6 voices)-
Posted 4 years ago #
-
I was wondering the same thing! It seems like there should be a way... Maybe someone else knows.
"Eat a live toad the first thing in the morning and nothing worse will happen to you the rest of the day."Posted 4 years ago # -
Could you use some math to take the angle of the character and just subtract that from the character's xspeed? Something like
slowdown = angle/10;
if (Math.abs(xspeed)-slowdown > 0) { xspeed -= slowdown; }Note: I just pulled that out of my brain, I don't know if it would actually work the way you want it to.
Just got back on the internet after losing my access for a week. Read more on Random Discussion.Posted 4 years ago # -
i just answered your topic on mochiads (im Whichello) https://www.mochiads.com/community/forum/topic/can-anyone-help-with-moving-forward?prev_url=%2Fcommunity%2F
Posted 4 years ago # -
I recommend that you learn some stuff about basic vector math/trig. Look up projection and components of vectors which should explain why the script works.
Basically what the script does is take a movement speed (vector) facing at an angle (like your character's rotation), then splits it into an x component and a y component.
This sort of math is really helpful in games.
Posted 4 years ago # -
moveRL = speed * Math.sin((_rotation)*(Math.PI/180))
moveUD = -speed * Math.cos((_rotation)*(Math.PI/180))Is what I have in my 'cache' fla...
Well, in FPA, it's set up something like:
this._x += this.RLx(this.moveRL)
this._y += this.RLy(this.moveRL)With the functions:
RLx = function(ex) { return (ex*(Math.cos((this._rotation)*(Math.PI/180)))) }
RLy = function(ey) { return (ey*(Math.sin((this._rotation)*(Math.PI/180)))) }When you're jumping, moveUD controls up and down motion, while moveRL controls only movement on the x axis, when you're on the ground, moveRL controls speed along the ground.
http://www.adobe.com/devnet/flash/
Click samples at the top, then the ActionScript 2.0 samples. Check out 'thrust movement.' That was some of the first code I ever learned, actually, heh.
Doodle, sketch, draw, design, fill notebooks with elaborate scenes, funny character designs, and gameplay ideas.
Find your own personal style and run with it. Craft characters and stories that you love.
Enjoy your own work, and don’t be afraid to show it off. Create.Posted 4 years ago #
Reply
You must log in to post.
