A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: lunar lander - loss of y friction

  1. #1
    Member
    Join Date
    Oct 2006
    Location
    Seattle, WA
    Posts
    45

    lunar lander - loss of y friction

    I have started a very simple lunar lander simulator. For some reason the y-axis friction is not working... Any ideas?
    Attached Files Attached Files
    Jan Zumwalt - http://www.flash.neatinfo.com

  2. #2
    Senior Member
    Join Date
    Dec 2006
    Posts
    274
    It is working, friction lowers velocity by defined amount/percentage. However you accelerate in y axis so velocity increases by amount 'n' even if friction is applied. Try to apply velocity instead of acceleration.

  3. #3
    Member
    Join Date
    Oct 2006
    Location
    Seattle, WA
    Posts
    45
    Thanks for the help.

    I see your point... However when I use velocity.y or x then I loose the relative thrust feature.

    Oh, well! It's starting to look like I will have to do some modest scripting :-(

    ----

    How do I adjust a value from a script? For example if I put the following line of code
    in the "exicute on every frame", I get an error? I assume I am not using the "dot" referancing correctly.

    lander.velocity.y += 5;
    Last edited by jwzumwalt; 12-24-2007 at 03:47 PM.
    Jan Zumwalt - http://www.flash.neatinfo.com

  4. #4
    Senior Member
    Join Date
    Dec 2006
    Posts
    274
    Thats true... after thinking this again, problem is not really acceleration but leaving it "on" after key event. You could reset relative_acceleration in "key up" or "on every frame" script. This way you apply acceleration (force) while pressing key (and thereby it adds velocity which is then slowed down by friction)

    Scripting help shows Sprites->"velocity and physics": velocity_y

  5. #5
    Member
    Join Date
    Oct 2006
    Location
    Seattle, WA
    Posts
    45
    To be brief, I did not include my attempt to use that too :-)
    i.e lander.velocity_y += 5;
    or lander.velocity.y = 5;

    Since "relative_acceleration.y" = 50 works for the keyboard instruction, I assumed that the .y should be used for velocity as well. I noticed that the documentation refers to _y in several places.

    I presume that I am missing something simple?
    Jan Zumwalt - http://www.flash.neatinfo.com

  6. #6
    Senior Member kusco's Avatar
    Join Date
    Nov 2001
    Posts
    681
    You should always use relative_acceleration_y

    The old style relative_acceleration.y still works for compatibility with older versions but may be removed one day. It gets translated internally by the compiler into relative_acceleration_y.
    Cheers,
    kusco
    (3DFA Support Team)

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