dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Smooth motion

  1. #1
    Zakarus's Tale Developer Zakarus2001's Avatar
    Join Date
    May 2001
    Location
    Here, lurking
    Posts
    237
    Okay say i have an "orb" that seeks something, i would rather have it go in a curved motion rather than a strait path toward it, I am not quite sure of the exact coding, but i know it would be something like this...

    Code:
    onClipEvent(EnterFrame){
       this._x += Math.sin(_x - objectToBeSeeked._x/180);
       this._y += Math.sin(_y - objectToBeSeeked._y/180);
    }
    I know somewhere in there I need to have Math.PI and maybe i need cosine, but I am not the greatest in Trig(i haven't done any radian conversions for almost 2 years now) but ahh I am sure you guys in here just laugh at this kind of Question... well thx for reading!

    ~Zakarus2001


    [Edited by Zakarus2001 on 04-26-2002 at 11:38 AM]

  2. #2
    Senior Member
    Join Date
    Jan 2002
    Posts
    368
    you have your basic easing equation to go straight towards a target:

    this._x+=(targetx-this._x)/5;
    this._y+=(targety-this._y)/5;

    5 being an arbitrary number to control speed.

    try using different numbers for the x and y components. instead of 5 and 5, try 2 and 10.

  3. #3
    Zakarus's Tale Developer Zakarus2001's Avatar
    Join Date
    May 2001
    Location
    Here, lurking
    Posts
    237

    lol

    I guess i was making that a bit too hard, lol well thx and thx again...

    ~Zakarus2001

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center