X movement affects acceleration (Y).

Hi. I want to make it to where my player character (the white box) falls at a constant rate. It's fine when it jumps and the user presses left or right until the character reaches the ground, but when the user presses either left, right, or left and right repeatedly and before the character reaches the ground, the acceleration stops for a second.

Here's my stuff:

gravity on/off
when all conditions are valid
attribute: self.gravity is true
accelerate, dir: 270, acceleration: 2000, relative to scene
otherwise
accelerate, dir: 270, acceleration: 0, relative to scene

xtragravity on/off
when all conditions are valid
attribute: self.xtragravity is true
accelerate, dir: 270, acceleration: 600, relative to scene
otherwise
accelerate, dir: 270, acceleration: 0, relative to scene

xtragravity l
when all conditions are valid
attribute: self.Motion.Linear Velocity.X < -1
attribute: self.Motion.Linear Velocity.Y < 0
attribute: self.floorcollide is false
change attribute: self.xtragravity to true
change attribute: self.noholdairL to true
otherwise
when all conditions are valid
attribute: self.noholdairL is false
change attribute: self.xtragravity to false

xtragravity l2
when all conditions are valid
attribute: self.noholdairL is true
change attribute: self.xtragravity to true
otherwise
when all conditions are valid
attribute: self.noholdairL is false
change attribute: self.xtragravity to false

xtragravity r
when all conditions are valid
attribute: self.Motion.Linear Velocity.X > 1
attribute: self.Motion.Linear Velocity.Y < 0
attribute: self.floorcollide is false
change attribute: self.xtragravity to true
change attribute: self.noholdairR to true
otherwise
when all conditions are valid
attribute: self.noholdairR is false
change attribute: self.xtragravity to false

xtragravity r2
when all conditions are valid
attribute: self.noholdairR is true
change attribute self.xtragravity to true
otherwise
when all conditions are valid
attribute: self.noholdairR is false
change attribute: self.xtragravity to false

noholdair
when all conditions are valid
actor receives event: overlaps or collides with actor of type: floor
change attribute: self.noholdairL to false
change attribute: self.noholdairR to false

floor collision
bounce when colliding with actor of type: floor

jmp
when all conditions are valid
actor receives event: key: k is down
attribute: self.kup is true
attribute: self.floorcollide is true
timer: for 1E-05 seconds (run to completion)
constrain attribute: self.Motion.Linear Velocity.Y to 680
change attribute: self.jumpyes to true
otherwise
timer: after 0.13 seconds (run to completion)
when all conditions are valid
actor receives event: key: k is up
attribute: self.Motion.Linear Velocity.Y > 0
attribute: self.floorcollide is false
change attribute: self.jumpyes to false
timer: after 0.5 seconds (run to completion)
when all conditions are valid
actor receives event: key: k is down
change attribute: self.jumpyes to false
when all conditions are valid
actor receives event: key: k is up
change attribute: self.jumpyes to false
otherwise
timer: after 1E-09 seconds (run to completion)
when all conditions are valid
actor receives event: key: k is down
attribute: self.floorcollide is false
attribute: self.jumpyes is false
change attribute: self.jumpyes to false
when all conditions are valid
actor receives event: key: k is up
attribute: self.floorcollide is false
attribute: self.jumpyes is false
timer: after 0.001 seconds (run to completion)
change attribute: self.jumpyes to false

kup
when all conditions are valid
actor receives event: overlaps or collides with actor of type: floor
actor receives event: key: k is up
change attribute: self.kup to true
otherwise
timer: after 0.01 seconds (run to completion)
change attribute: self.kup to false

jumpyes
when all conditions are valid
attribute: self.jumpyes is false
when all conditions are valid
attribute: self.floorcollide is false
when all conditions are valid
attribute: self.Motion.Linear Velocity.Y > 0
change attribute: self.Motion.Linear Velocity.Y to 0

l
when all conditions are valid
actor receives event: key: a is down
change velocity, dir: 180, speed: 200, relative to actor
otherwise
when all conditions are valid
actor receives event: key: d is up
change velocity, dir: 0, speed: 0, relative to actor

r
when all conditions are valid
actor receives event: key: d is down
change velocity, dir: 0, speed: 200, relative to actor
otherwise
when all conditions are valid
actor receives event: key: a is up
change velocity, dir: 0, speed: 0, relative to actor

floorcollide
when all conditions are valid
actor receives event: overlaps or collides with actor of type: floor
change attribute: self.floorcollide to true
otherwise
change attribute: self.floorcollide to false

Comments

  • zeldakidzeldakid Member Posts: 3

    Better organized version below, sorry for any inconvenience.

    Hi. I want to make it to where my player character (the white box) falls at a constant rate. It's fine when it jumps and the user presses left or right until the character reaches the ground, but when the user presses either left, right, or left and right repeatedly and before the character reaches the ground, the acceleration stops for a second.

    Here's my stuff:

    gravity on/off
    when all conditions are valid
    attribute: self.gravity is true
    accelerate, dir: 270, acceleration: 2000, relative to scene
    otherwise
    accelerate, dir: 270, acceleration: 0, relative to scene

    xtragravity on/off
    when all conditions are valid
    attribute: self.xtragravity is true
    accelerate, dir: 270, acceleration: 600, relative to scene
    otherwise
    accelerate, dir: 270, acceleration: 0, relative to scene

    xtragravity l
    when all conditions are valid
    attribute: self.Motion.Linear Velocity.X < -1
    attribute: self.Motion.Linear Velocity.Y < 0
    attribute: self.floorcollide is false
    change attribute: self.xtragravity to true
    change attribute: self.noholdairL to true
    otherwise
    when all conditions are valid
    attribute: self.noholdairL is false
    change attribute: self.xtragravity to false

    xtragravity l2
    when all conditions are valid
    attribute: self.noholdairL is true
    change attribute: self.xtragravity to true
    otherwise
    when all conditions are valid
    attribute: self.noholdairL is false
    change attribute: self.xtragravity to false

    xtragravity r
    when all conditions are valid
    attribute: self.Motion.Linear Velocity.X > 1
    attribute: self.Motion.Linear Velocity.Y < 0
    attribute: self.floorcollide is false
    change attribute: self.xtragravity to true
    change attribute: self.noholdairR to true
    otherwise
    when all conditions are valid
    attribute: self.noholdairR is false
    change attribute: self.xtragravity to false

    xtragravity r2
    when all conditions are valid
    attribute: self.noholdairR is true
    change attribute self.xtragravity to true
    otherwise
    when all conditions are valid
    attribute: self.noholdairR is false
    change attribute: self.xtragravity to false

    noholdair
    when all conditions are valid
    actor receives event: overlaps or collides with actor of type: floor
    change attribute: self.noholdairL to false
    change attribute: self.noholdairR to false

    floor collision
    bounce when colliding with actor of type: floor

    jmp
    when all conditions are valid
    actor receives event: key: k is down
    attribute: self.kup is true
    attribute: self.floorcollide is true
    timer: for 1E-05 seconds (run to completion)
    {constrain attribute: self.Motion.Linear Velocity.Y to 680
    change attribute: self.jumpyes to true}
    otherwise
    timer: after 0.13 seconds (run to completion)
    {when all conditions are valid
    actor receives event: key: k is up
    attribute: self.Motion.Linear Velocity.Y > 0
    attribute: self.floorcollide is false}
    change attribute: self.jumpyes to false
    timer: after 0.5 seconds (run to completion)
    {when all conditions are valid
    actor receives event: key: k is down
    change attribute: self.jumpyes to false}
    when all conditions are valid
    actor receives event: key: k is up
    change attribute: self.jumpyes to false
    otherwise
    timer: after 1E-09 seconds (run to completion)
    {when all conditions are valid
    actor receives event: key: k is down
    attribute: self.floorcollide is false
    attribute: self.jumpyes is false
    change attribute: self.jumpyes to false
    when all conditions are valid
    actor receives event: key: k is up
    attribute: self.floorcollide is false
    attribute: self.jumpyes is false
    timer: after 0.001 seconds (run to completion)
    {change attribute: self.jumpyes to false}}

    kup
    when all conditions are valid
    actor receives event: overlaps or collides with actor of type: floor
    actor receives event: key: k is up
    change attribute: self.kup to true
    otherwise
    timer: after 0.01 seconds (run to completion)
    {change attribute: self.kup to false}

    jumpyes
    when all conditions are valid
    attribute: self.jumpyes is false
    {when all conditions are valid
    attribute: self.floorcollide is false
    {when all conditions are valid
    attribute: self.Motion.Linear Velocity.Y > 0
    change attribute: self.Motion.Linear Velocity.Y to 0}}

    l
    when all conditions are valid
    actor receives event: key: a is down
    change velocity, dir: 180, speed: 200, relative to actor
    otherwise
    when all conditions are valid
    actor receives event: key: d is up
    change velocity, dir: 0, speed: 0, relative to actor

    r
    when all conditions are valid
    actor receives event: key: d is down
    change velocity, dir: 0, speed: 200, relative to actor
    otherwise
    when all conditions are valid
    actor receives event: key: a is up
    change velocity, dir: 0, speed: 0, relative to actor

    floorcollide
    when all conditions are valid
    actor receives event: overlaps or collides with actor of type: floor
    change attribute: self.floorcollide to true
    otherwise
    change attribute: self.floorcollide to false

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    It's awesome that you posted all of the rules... although a lot of work to type that all in! You might consider posting a link to download the project file (stripped of anything secretive/valuable) because I suspect you're going to limit the number of people willing to read through a wall of text.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • zeldakidzeldakid Member Posts: 3

    Nevermind, fixed it. Used change attribute: self.motion.linear velocity.x for x movement instead of change velocity.

Sign In or Register to comment.