[SOLVED]Strange behaviour of 8 Direction...

Get help using Construct 2

Post » Sun Mar 08, 2015 7:00 pm

I saw someone recreate Gauntlet in Javascript earlier today and I decided to try to do the same. I started about 20 minutes ago, and I ran into this strange problem with the animations. The way they are set up is that instead of responding to user input I check for 8 Direction's VectorX and VectorY variables so I can reuse the same animation code for the player and for other stuff. Anyways, it didn't work... Thankfully, I've gotten into a habit of opening my project in debug mode first and I noticed that when I press the up arrow VectorY is set to 100, and the Player object's X variable is changing correctly, however I also noticed that VectorX variable was set to like -6.32482347( :?: :!: ) or something but it's not applying to the player position. I just want to know if I somehow screwed something up, or my Construct 2 version is just wierd(I haven't updated in a while). I'll try update to the newest version to see if it fixes my issue...

Update: I've downloaded the latest version, and it didn't fix the problem. These 'fantom numbers' are added when I go down, left or up.

I also forgot to upload to .capx file...
You do not have the required permissions to view the files attached to this post.
Last edited by tarik00555 on Sun Mar 08, 2015 8:25 pm, edited 1 time in total.
Banned User
B
6
S
3
Posts: 105
Reputation: 1,170

Post » Sun Mar 08, 2015 8:13 pm

Isn't this just a case of computer precision that has been discussed many times before?

I haven't looked at your capx yet but generally this is caused by assuming a value will be exactly = to a particular value, such 0,1,2....but computers don't always produce such values.

Maybe try forcing the value to a rounded int will help, or don't check for exact values.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
131
S
29
G
81
Posts: 5,328
Reputation: 56,630

Post » Sun Mar 08, 2015 8:24 pm

Yup! Simply rounding the values fixed the problem. Thanks a lot!
Banned User
B
6
S
3
Posts: 105
Reputation: 1,170


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 9 guests