move actor

Hi was just curious, what wondering a command to move actor 1 based on touch.

example to move it right, based on how long you hold the touch down for.

for example, i hold right actor called "RIGHT" and it would need to move actor1 based on how long i keep it pressed.

basic commands for moving an actor really based on touch/hold.

I imagine, its going to be based on release to top it, i would guess.

any example would be great thanks.

Oh, id also like if possible, to use it in with attributes or accelerate, so i can fine tune it later depending on the level

Comments

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
  • IceboxIcebox Member Posts: 1,485

    Create 2 game booleans , call them right and left

    Create touch button actors (right and left)

    Right button Rule
    if touch is inside
    change game.right to true
    otherwise
    change game.right to false.

    Left button Rule
    if touch is inside
    change game.left to true
    otherwise
    change game.left to false.

    Main Player Actor Rule

    Rule- if game.right and game.left is false
    constrain motion linear velocity x to 0
    Otherwise ( add 2 rules )
    1- if game.right is true
    constrain motion linear velocity x to 150 or accelerate right or move right

    2-if game.left is true
    constrain motion linear velocity x to -150 or accelerate left or move left

  • sonicm3sonicm3 Member Posts: 141

    thats both, although very similar but im working with icebox's first as i can see the text, but i watched video too and almost the same. Its working great but, only issue i have is, when my landscape map goes downhill, the actor sort of flies across, rather than falling my map. i have gravity turned on too, so not sure why the actor is flying and not falling rapidly?

  • IceboxIcebox Member Posts: 1,485

    dont use move for movement instead constrain attribute self.motion linear velocity x to 100(speed)

  • sonicm3sonicm3 Member Posts: 141

    Perfect thanks mate.
    Just to add to this too while we are on the subject.
    when moving right and left, im using a series of actors to create a floor. when this main actor hits a slight incline, he stops and cant get over it. can it be adjusted so it can just continue walking over small objects instead of pressing up

  • IceboxIcebox Member Posts: 1,485

    @sonicm3 try changing bounciness of the actor to 0.1

  • sonicm3sonicm3 Member Posts: 141

    yea already set for 0.1, and gravity of scene is 99999

  • IceboxIcebox Member Posts: 1,485

    @sonicm3 hmm I don't know then, I guess start another thread with the problem or wait and see if someone can help , sorry .

  • sonicm3sonicm3 Member Posts: 141

    i think, ill just fine tune the floor level, thanks for the great help mate i really appreciate it so much, saved me so much time. thanks also to jamie to vid.

  • sonicm3sonicm3 Member Posts: 141

    Oh dam, just quickly, i know by the above example how to go up and down ect, but what about jump?

  • IceboxIcebox Member Posts: 1,485
    edited April 2016

    @sonicm3 said:
    Oh dam, just quickly, i know by the above example how to go up and down ect, but what about jump?

    if actor overlaps or collides with ground and space bar is pressed
    change attribute self.motion.linear.velocity.Y to 500( any number you want)

    thats it. (make sure you have accelerate with direction (270)

  • sonicm3sonicm3 Member Posts: 141

    wow perfect man, lol awsome.
    only issue i have now is, if i keep pressing jump actor over n over he keeps jumping forvever. Can i add some sort of constrain 0 command somewhere?

  • IceboxIcebox Member Posts: 1,485

    @sonicm3 said:
    only issue i have now is, if i keep pressing jump actor over n over he keeps jumping forvever. Can i add some sort of constrain 0 command somewhere?

    It shouldnt jump forever if you add in a condition that it would only jump if it collides with the ground thats strange

    Are you sure u added if overlaps or collides with ground and if key is pressed ?

    If you did and you still have the same issue , you can create a boolean self attribute call it grounded .. add a rule .. if actor overlaps or collides with ground change attribute grounded to true otherwise grounded is false .
    Then add this rule if grounded is true and
    Key is pressed change attribute self.linear velocity y to 300 .. so now it would jump only if its grounded but i still dont see why the first method doesnt work..

    This method with grounded usually is used with constraining a feet actor to your main actor and making the grounded boolean a game attribute ..but try it

  • sonicm3sonicm3 Member Posts: 141
    edited April 2016

    trying it now

  • IceboxIcebox Member Posts: 1,485

    I dont really know what you did but no need for timer , i cant create a demo right now since im outside , i recomend you go to youtube and search gamesalad platform tutorial by jamie you will find everything you need

  • sonicm3sonicm3 Member Posts: 141
    edited April 2016

    do you mean to add a collosion inside the actor that jumps?

    if game.jump is true
    if actor collides with ground
    do self.motion.linear.velocity.y 300 ~?

    EDIT, yes works perfect.. sorry yeah i messed it up and now added it perfect thankyou mate

Sign In or Register to comment.