Having a problem using "set position" for player.

0 favourites
  • 10 posts
From the Asset Store
Players follower. use it for anything which follows the player
  • Hey all,

    I'm having a problem in one of my games, and I'm not sure if this is a bug or not so I don't want to post it to the "report a bug" thread just yet.

    I'll post my cap.x below, but basically what's going on is that I have events set up (the last four on the event sheet in the cap.x) so that when the playerbox is overlapping a stairway and the player presses "S," the playerbox is repositioned to the "exit" of that stairway. For some reason the mechanic works fine when the player is going from a higher elevation to a lower elevation, but when the player is on an "up" stairway (decreasing in x value), the playerbox just gets repositioned to the center of the stairway he's overlapping.

    Any suggestions?

    https://www.dropbox.com/s/cz4zmq9jxsvhbo1/Wald0BUG.capx

    All help is extremely appreciated. I'm working towards submitting a game to the Newgrounds Construct 2 GameJam, and I only have until June 15th to push it out.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I get a JavaScript error. The game doesn't run. Hard to see the issue.

  • That was happening to me a few times too. It alternated between giving me a JavaScript error and opening. I haven't played with anything out of the ordinary, so I'm not sure why it's happening.

  • Well the capx appears to be missing some png files (the loading icons and the favicons for the project), this might be an issue in the long run and might cause the javascript issue.

    As for your problem, simply add a system condition "Else" to events 29 to 31.

    It's just a (common) issue of how events work. You press S, the code testes if you're positioned over a "up" stairs, yes ? then it moves the character.

    Then it testes is the character positioned over a "down" stairs ? Well, now yes it is since I moved it as a result of my very previous test. So moving the character again, you are under the impression it hasn't moved from the "up" stairs when actually in the same tick, it moved twice.

    Adding the "Else" condition allows you to prevent that behavior and the checks to perform as you intend.

    No bug here.

  • Just a quick suggestion. Rather than hard-coding the position for the doorways, I would add an extra image point to the doorway and then use the Set Position to Object action. If you have many doors, it can save you lots of time.

  • Well the capx appears to be missing some png files (the loading icons and the favicons for the project), this might be an issue in the long run and might cause the javascript issue.

    Thanks! I just opened up the caproj, and it gave me a list of them. I didn't realize I was missing them. Is there a way to replace them, or should I start a new project and re-import the assets, to avoid future issues?

    As for your problem, simply add a system condition "Else" to events 29 to 31.

    It's just a (common) issue of how events work. You press S, the code testes if you're positioned over a "up" stairs, yes ? then it moves the character.

    Then it testes is the character positioned over a "down" stairs ? Well, now yes it is since I moved it as a result of my very previous test. So moving the character again, you are under the impression it hasn't moved from the "up" stairs when actually in the same tick, it moved twice.

    Adding the "Else" condition allows you to prevent that behavior and the checks to perform as you intend.

    Thank you so much. I didn't even think of that. It explains why when he's on an "up stairs" he gets repositioned to the position for the "down stairs." I think I'm doing your fix wrong though. When I go to add "else" to the events, it comes up with red text warning me that '"else" is not valid here', and if I right click and add "else" events inbetween the events it doesn't work. I feel like this is a simple concept I'm not grasping. Haha.

    EDIT: Nevermind!! I just had to indent the events properly in order to get this to work. I'm so grateful for your help, thanks!

    Just a quick suggestion. Rather than hard-coding the position for the doorways, I would add an extra image point to the doorway and then use the Set Position to Object action. If you have many doors, it can save you lots of time.

    Thanks for the tip!

    Originally I had it set to the origin just to test to see if it worked, but I tried switching to using the position to see if for some reason those events weren't working because of their being set to the origin.

  • The files you are missing are in the folder hierarchy in the "Project" tab.

    They are under Files/Icon.

    Simply open each file and open an image, like for sprites in the image editor.

    Save the capx as a new file (make a new iteration), it should help make sure the capx does not "corrupt" further.

  • You're a lifesaver, Kyatric. Thank you!

  • Can I just delete these folders? I'm not sure what the icons and loading logo are supposed to be.

  • Nevermind!

    I saved a blank project to get the files from.

    Thank you!!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)