A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: scooter wheels follow ground shape?...

  1. #1
    Senior Member
    Join Date
    Jun 2003
    Location
    La Mirada California
    Posts
    396

    scooter wheels follow ground shape?...

    hey can someone help me... i need to make a game where theres a scooter and its gonna follow the ground. its going to be able to manual and jump too... all i need is to figure out how to make it so the front and back tire move down untill they both hit the ground. so if the ground was going down and i just jumped i need the back tire to stop first, then it to rotate clockwise untill the front tire hits...
    i was just going to use hittest but that wont work because the ground will have ramps and stuff...

    anyone know?.. tell me if i need to explaine it more

  2. #2
    Lunatic Baukereg's Avatar
    Join Date
    Nov 2000
    Location
    Lowlands
    Posts
    853
    Say, your wheel is 20 px high, and the 0:0 point is in the middle, and it is called 'wheel1'. The ground is stored in a MC called 'ground'.

    code:

    while ((ground.hitTest(wheel1._x, wheel1._y+10, true)==false) {
    wheel1._y++;
    }


  3. #3
    Ihoss
    Guest
    I think I have a file in my footer

  4. #4
    Senior Member
    Join Date
    Jun 2003
    Location
    La Mirada California
    Posts
    396
    yeah but wont that only make it move down from when i jump? and it will be in the same horizontal position if the ground slants up?

    i need it to rotate with the ground so front and back are always touching... and when ill manual itll do almost same thing as that but with a rotation thing so when i let go, itll rotate untill the front tire touches. then same thing when gonig uphill

  5. #5
    self-portrait Kianis's Avatar
    Join Date
    Feb 2004
    Location
    Stockholm, Sweden
    Posts
    425
    I'd make the ground (including ramps etc) a graph and interpolate the y-value.

  6. #6
    Senior Member
    Join Date
    Jun 2003
    Location
    La Mirada California
    Posts
    396
    what do you mean?..

  7. #7
    self-portrait Kianis's Avatar
    Join Date
    Feb 2004
    Location
    Stockholm, Sweden
    Posts
    425
    To interpolate basically means you assume what the y-value is by looking at the closest points in a graph.. Since a swf explains more then 1000 words :
    http://www.strille.net/works/misc/linearInterpolation/

  8. #8
    Lunatic Baukereg's Avatar
    Join Date
    Nov 2000
    Location
    Lowlands
    Posts
    853
    I think that's not what brentW505 means (although it is very cool). I think he means that, if the car is rotated 30%, the wheels need to find the 'horizon' below them in a line of 30%. In cases the car drives on/off a hill.

  9. #9
    Senior Member
    Join Date
    Jun 2003
    Location
    La Mirada California
    Posts
    396
    yeah, i can get one object's point to follow the ground's y. but how do i get the whole scooter's two wheels to always be touching the ground? its going to be one whole object with maybe two symbols of the wheels inside it. how do i get the scooter to rotate so that the wheels always touch the ground?

    its like a skateboard or biking game... its a side view, and you'll be able to jump off ramps and jump flat ground and do manuals... how can get this to work?

  10. #10
    Ihoss
    Guest
    I obviously didnt

    This has the function you want. You have to pull it out of the file, because it is actually a game.
    Attached Files Attached Files

  11. #11
    Senior Member
    Join Date
    Jun 2003
    Location
    La Mirada California
    Posts
    396
    ok... i have no idea what how that game works... nothing happens when you play it like it is... i had to move the stop to the second frame... then it works, but i dont know whats going on... whats the deal with the red box?... i dont know where the code is....
    think you can find it and post it?... or explain it to me?

  12. #12
    self-portrait Kianis's Avatar
    Join Date
    Feb 2004
    Location
    Stockholm, Sweden
    Posts
    425
    Sorry, I didn't know the answer to your question, my post were just ment to show another aproach at finding the ground (besides hitTest). :$

    But if you would use the method of interpolating it would be easy to get the correct angle for when both wheels touch the ground.

    Anyhow Ihoss' script seems to work fine ^^

  13. #13
    Ihoss
    Guest
    Ok, I copied some of the code from the game into this file and I also simplified it a lot. Hope this helps you
    Attached Files Attached Files

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