Having a problem using "set position" for player.

Get help using Construct 2

Post » Sat May 24, 2014 12:30 am

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.
B
9
S
2
Posts: 37
Reputation: 739

Post » Sat May 24, 2014 1:55 am

I get a JavaScript error. The game doesn't run. Hard to see the issue.
B
75
S
23
G
3
Posts: 673
Reputation: 9,293

Post » Sat May 24, 2014 1:58 am

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.
B
9
S
2
Posts: 37
Reputation: 739

Post » Sat May 24, 2014 7:58 am

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.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
296
S
119
G
96
Posts: 7,328
Reputation: 71,298

Post » Sat May 24, 2014 9:21 am

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.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
137
S
31
G
87
Posts: 5,548
Reputation: 60,440

Post » Sat May 24, 2014 1:41 pm

Kyatric wrote: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?

Kyatric wrote: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!

zenox98 wrote: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.
B
9
S
2
Posts: 37
Reputation: 739

Post » Sat May 24, 2014 7:47 pm

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.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
296
S
119
G
96
Posts: 7,328
Reputation: 71,298

Post » Sun May 25, 2014 12:33 am

You're a lifesaver, Kyatric. Thank you!
B
9
S
2
Posts: 37
Reputation: 739

Post » Sun May 25, 2014 12:42 am

Can I just delete these folders? I'm not sure what the icons and loading logo are supposed to be.
B
9
S
2
Posts: 37
Reputation: 739

Post » Sun May 25, 2014 12:44 am

Nevermind!

I saved a blank project to get the files from.

Thank you!!
B
9
S
2
Posts: 37
Reputation: 739


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests