How can i make my actor face the way he enetred a scene?

sonicm3sonicm3 Member Posts: 141
edited April 2016 in Working with GS (Mac)

Hi how can i make the actor face the correct way when he eneters a scene.

example, if i animate right actor... and left actor fine. when he stops..

1) how do i make it show the way he is facing. (assuming this will work for when he enterers a scene too )

«1

Comments

  • IceboxIcebox Member Posts: 1,485
    edited April 2016

    If your image sequence is facing right:
    change attribute flip horizontally to false when you want to face right
    change attribute flip horizontally to true when you want to face left

    If your image sequence is facing left:
    change attribute flip horizontally to true when you want to face right
    change attribute flip horizontally to false when you want to face left

  • sonicm3sonicm3 Member Posts: 141

    thanks did that, think it works, but, when i move right.. its perfect.. when i move right, perfect. but as soon as he come to a stand still, "white square".

  • sonicm3sonicm3 Member Posts: 141

    yea it works, but the white square now only appears if idle, changes scene.. then when i start moving again, its fine. so its only at a stop its now a white square

  • SocksSocks London, UK.Member Posts: 12,822
    edited April 2016

    @sonicm3 said:
    thanks did that, think it works, but, when i move right.. its perfect.. when i move right, perfect. but as soon as he come to a stand still, "white square".

    I bet someone could work your problem out in 30 seconds if they saw the rules that are causing the problem, without seeing the rules the process can be slow and difficult, relying mainly on guesswork.

  • sonicm3sonicm3 Member Posts: 141

    Hi thanks, the example of the move left rules is exactly..

    when all of following..
    if GAME.LEFT = TRUE
    CONSTRAIN SELF,MOTION.LINEARVELOCITY.X = -180
    ANIMATE (series of left motions)
    CHANGEATTRIBUTE = flip horizontally = TRUE
    CHANGEATTRIBUTE = flip horizontally = FALSE

  • SocksSocks London, UK.Member Posts: 12,822
    edited April 2016

    @sonicm3 said:
    Hi thanks, the example of the move left rules is exactly..

    when all of following..
    if GAME.LEFT = TRUE
    CONSTRAIN SELF,MOTION.LINEARVELOCITY.X = -180
    ANIMATE (series of left motions)
    CHANGEATTRIBUTE = flip horizontally = TRUE
    CHANGEATTRIBUTE = flip horizontally = FALSE

    We'd really need to see all the rules that affect the actor. It's perfectly possible for the left move rules to be working while the right move contains an error . . . or some interaction between the two cause the 'white square' issue . . . or the animation behaviour might be involved but we are unable to see its settings . . . . and so on . . . . and by seeing one rule no one is really able to determine what the rest state of the actor is . . . and so on, basically rules effect each other, they interact, so just seeing one part of the rules that effect the actor doesn't really tell us enough.

    For example, if this were a calculation, and the calculation kept producing an unexpected result, then showing just a couple of numbers from the calculation wouldn't be enough to locate the issue, you'd need to see the whole calculation.

    Could you do a screen grab of the code ?

    . . . . . . . . . . . . . . . .

    On a side note: a couple of notes not related to your 'white square' issue:

    You don't really need to constrain linear velocity to a value, once you give an actor a linear velocity it will move by itself from then on at the speed you specified . . . so most times you can use a change attribute or change velocity behaviour, these fire just once, whereas a constrain fires 60 times a second, so for example after 40 seconds of gameplay a change attribute would have processed 1 instruction, where as the constrain would have processed 2,400 instructions (and would continue at this rate).

    It's not really a big issues with a few constrains, or even 10 or 20 constrains, but it's always a good idea to make your game as efficient as possible, and if left unchecked bloated code and unneeded processor cycles can add up to a glitchy and stuttering game.

    Imagine it like this, change attribute changes your actor from white to red, where as constrain changes your actor from white to red, and then continues to change it to red 60 times a second, even though it's already red.

    Also . . . if you have two change attributes doing opposite things like this . . .

    CHANGEATTRIBUTE = flip horizontally = TRUE
    CHANGEATTRIBUTE = flip horizontally = FALSE

    . . . you will run into issues, the first one (true) probably won't register as it is immediately cancelled out by the second.

  • IceboxIcebox Member Posts: 1,485
    edited April 2016

    @sonicm3 said:
    Hi thanks, the example of the move left rules is exactly..

    when all of following..
    if GAME.LEFT = TRUE
    CONSTRAIN SELF,MOTION.LINEARVELOCITY.X = -180
    ANIMATE (series of left motions)
    CHANGEATTRIBUTE = flip horizontally = TRUE
    CHANGEATTRIBUTE = flip horizontally = FALSE

    @sonicm3 Hey , you got it a bit wrong there , why would you put flip horizontally true and flip horizontally false under the same rule. You have to think about what you do thats why we told you over and over again watch gs logic series watch tutorials on youtube it wont take time trust me. You will figure out everything.

    You can have many ways to animate your actor there are different methods , what you need to do is understand what you want first. Thats what i do and keep everything organized. There are other better ways than this but this is what i personally prefer.

    Movement idle , right and left
    if right and left are up , motion linear velocity = 0 otherwise 2 rules ( if right is down constrain motion linear velocity to +180 ) ( if left is down constrain motion linear velocity x to -180 )

    You want your actor to have an idle image or animation if hes standing
    if motion linear velocity x = 0 and overlaps or collides with ground
    Animate idle animation

    If the actor moves right or left on ground you want him to animate walk
    if motion linear velocity x is not = 0 and overlaps or collides with ground
    Animate walking animation

    If the actor jumps you want him to animate jump
    if motion linear velocity y is > 0 , animate jump

    When you want to flip horizontally depending on your image.( lets say facing right)
    if motion linear velocity x > 0 , flip horizontally to true , Otherwise flip horizontally to false

    as i said there are different better ways , look into tutorials on youtube even if your not interested on the type of game the tutorial is about. You will learn something new everytime. I hope this helps

  • sonicm3sonicm3 Member Posts: 141

    yea, thanks socks. i took out the flip statement that states TRUE and it does the same job with it out. Yeah, it seems to be obviously a white square as ive no picture assigned, but it shows white square on the following ways.

    1) as soon as game loads.
    2) as soon as you enter a next scene

    ill try and screen grad the code if i can.

  • sonicm3sonicm3 Member Posts: 141

    Thanks ice, yea im trying that now

  • SocksSocks London, UK.Member Posts: 12,822

    @sonicm3 said:
    . . . it shows white square . . . // . . . as soon as game loads.

    Is there an image applied to the actor in the scene ?

  • sonicm3sonicm3 Member Posts: 141

  • sonicm3sonicm3 Member Posts: 141

    the animation boxes are full i just deleted them for the screenshots

  • IceboxIcebox Member Posts: 1,485

    @Socks said:
    You don't really need to constrain linear velocity to a value, once you give an actor a linear velocity it will move by itself from then on at the speed you specified . . . so most times you can use a change attribute or change velocity behaviour, these fire just once, whereas a constrain fires 60 times a second, so for example after 40 seconds of gameplay a change attribute would have processed 1 instruction, where as the constrain would have processed 2,400 instructions (and would continue at this rate).

    Your right but from my experience with side scrolling games in particular, constraining motion velocity is better than change attribute cause of the jump issue , it doesn't allow you to jump forward or backward when your not on ground or when you collide with a platform while jumping the change attribute goes off. So thats why i kept telling him to constrain unless i got it wrong.

  • sonicm3sonicm3 Member Posts: 141
    edited April 2016

    what about if right key press is "de-pressed" show the one image if standing right?

    *ignore what i said, it wouldnt work as im looking at it from the keypad not the actor.

  • sonicm3sonicm3 Member Posts: 141

    @Socks said:

    @sonicm3 said:
    . . . it shows white square . . . // . . . as soon as game loads.

    Is there an image applied to the actor in the scene ?

    sorry missed this one, no there is no image applied.
    as i dont want a image of idling, really need it to be either facing left or right.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited April 2016

    okay I see an issue your move rules left and right need to have the opposite condition as well as you could fire them both at once causing a logic conflict. You need to add when right is false to your left rule and when left is false to your right rule.

  • sonicm3sonicm3 Member Posts: 141
    edited April 2016

    Ok thanks, i made that update now.

    Also just an update on this question.
    I gave the actor a image now and it no longer shows white square (obviously) but the image i gave him is facing right...

    @Lost_Oasis_Games and @socks @Icebox
    so the 2 issues i have is

    1) so now everytime he goes through the left door, his image is facing right until i press the left arrow key.
    just so i can try and simplify it a bit. any thoughts to get him, so when goes through the left door, hes facing left.

    2) but also, so its a continues movement? at the moment, he goes through the door, stands till until i repress move. is there a way its one continues movement without having to re-press the key again when he changes from scene to scene?

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    The way you have it coded is not the way I would do it at all. Overall it's really quite dysfunctional. Did you watch the videos on making a platformer? If you had you would have learned proper movement and facing et... The way you are coding this game is going to lead to more and more issues as you add more code, as evidenced by all your threads. In a normal platformer type movement and image display those two branches of logic are separated so you don't end up with the facing issue you have. What you will need to do is have a Boolean that tracks the last facing direction. So add a Boolean game.facing right is true, left is false.

    When right is pressed change attribute game.facing to true.

    When left is pressed change game.facing to false.

    New rule (inside your rule where to set velocity to zero)

    When game.facing is true

    Change image to right

    New rule

    When game.facing is false

    Change image to left.

    This isn't the most effective way but should work.

  • sonicm3sonicm3 Member Posts: 141

    Hi yea i watched tones of videos and all worked fine, but the way i need it designed is very unique, At the moment, its working perfect, fine tuned, just these 2 issues i have as above.
    But

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited April 2016

    @sonicm3 said:
    Hi yea i watched tones of videos and all worked fine, but the way i need it designed is very unique, At the moment, its working perfect, fine tuned, just these 2 issues i have as above.
    But

    Just because things work doesn't mean it's right. Pluse no offense but your design is not unique. We veterans have been building games for years and understand proper code in all situations. We know dysfunctional code when we see it. Logic is logic period. As you build it out and include more possible scenarios more issue will present. Trust me on this.

  • sonicm3sonicm3 Member Posts: 141
    edited April 2016

    sorry when i say design, i mean from what i want out of the game. Ive been making games for years for spectrum. so im just adjusting to gamesalad over these past few days.
    The code i have looking at it is so simple, and not had any issue. the only issue i have is, when going through left door im facing right, thats it. as that the image i have as my main character facing right

  • sonicm3sonicm3 Member Posts: 141
    edited April 2016

    Its not the movment i need help with.
    Its the image. Here is what i have

    actor moves right , WORKS. IMAGE RIGHT
    actor move left, WORK IMAGE LEFT

    however, when i have no image assigned to the actor its obviously white square.
    When i assign my "facing right" image to the actor so he spawns always facing right, thats fine.

    The ONLY issuue i have is, when my actor goes through a LEFT door, hes facing "right" thats it.(as hes been assigned that image for it to spawn correctly)
    so i need it so when he goes through left door, hes facing left.

  • IceboxIcebox Member Posts: 1,485

    @sonicm3 Here is a demo you can check how its done

    Hope it helps

  • sonicm3sonicm3 Member Posts: 141

    thankyou so much mate, ill dl it now

  • IceboxIcebox Member Posts: 1,485
    edited April 2016

    @sonicm3 Just to explain sorry , You have to keep in mind , self attributes restart when the scene changes but game attributes don't, thats why you see it resets every time you go into a new scene cause the flip horizontally attribute is a self attribute you will find it on the actor's graphics section. In this case you will have to create a game level attribute , boolean for example or integer what ever you prefer.

    Create a game attribute boolean call it flip or anything

    then add a rule on the actor
    if flip is true change flip horizontally to true , otherwise change flip horizontally to false

    on your move right and move left
    if right is down or pressed , change game.flip to true
    if left is down or pressed , change game.flip to false

    goodluck :)

  • sonicm3sonicm3 Member Posts: 141

    haha, perfect explanation icebox, thankyou so much mate, brillaint!!!

  • sonicm3sonicm3 Member Posts: 141

    @icebox just a really quick one mate, everything works as it should now perfect. Only slight issue is, when i press the "moveleft" button he walks backwards left, until i press it again and its fine. Its like i have to double click it for some reason, maybe i have doubled up some command somewhere maybe?

  • IceboxIcebox Member Posts: 1,485

    @sonicm3 said:
    @icebox just a really quick one mate, everything works as it should now perfect. Only slight issue is, when i press the "moveleft" button he walks backwards left, until i press it again and its fine. Its like i have to double click it for some reason, maybe i have doubled up some command somewhere maybe?

    @sonicm3 in the demo you mean ? or on your own project ? can you show me what you did ? I can't tell this way sorry

  • SocksSocks London, UK.Member Posts: 12,822

    @sonicm3 said:
    @icebox just a really quick one mate, everything works as it should now perfect. Only slight issue is, when i press the "moveleft" button he walks backwards left, until i press it again and its fine. Its like i have to double click it for some reason, maybe i have doubled up some command somewhere maybe?

    Glad you got this sorted, Icebox's demo looks (typically) excellent !

    One thing I would add is the point I made earlier in this thread, it's pretty much impossible to resolve issues like this without seeing your code.

    If you upload a screenshot of the code people can check it out and see if they can locate the issue, without seeing the code all people can do is make guesses.

Sign In or Register to comment.