How do I correct the character grid-based movement?

Get help using Construct 2

Post » Mon Nov 02, 2015 12:05 am

I'm creating an grid based movement for a tactical based rpg, on paper, my code is fine, but coding was another story.

Basically, a function moves a stance of an object to the left, first checking if it has no obstacle.
If there isn't, then a global variable picks the new position(character.X -32 ) and then it starts moving to the left.
Image

The problem is it never stops, since the object moves not in round pixels. Construct kinda of interpolates the movement and as such, the value of the global variable is never achieved by the object in movement...
Image

The project is already configured to retro-style.
What can I do to correct this position?

Thanks :)
B
6
S
1
G
2
Posts: 26
Reputation: 1,477

Post » Mon Nov 02, 2015 4:41 am

So as long as it doesn't detect an obstacle it continues to go left... sounds like its doing what your asking of it.

How are you stopping it?

Have you tried using System:Trigger Once in the event conditions?
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
65
S
17
G
8
Posts: 636
Reputation: 9,333

Post » Mon Nov 02, 2015 6:45 am

Couldn't you, instead of "Xdest=Characters.x" use "XDest<Characters.x + 2" (2 or 4 or whatever works)

then set the Xdest to Characters.x
B
226
S
60
G
33
Posts: 902
Reputation: 39,989

Post » Mon Nov 02, 2015 11:34 am

chrisinfinger wrote:So as long as it doesn't detect an obstacle it continues to go left... sounds like its doing what your asking of it.

How are you stopping it?

Have you tried using System:Trigger Once in the event conditions?


The thing that is wrong is not the collision detection, but the movement by itself.

The movement input keys only work if the object is not moving. And the movement only happens a single 32pixels at time to the left if there is no offset obstacle 32 pixels to the left of it. This would

Since it checks for obstacles before moving and the way the game will work, there will be really no need to check for collisions outside of this scope I believe.


Paradox wrote:Couldn't you, instead of "Xdest=Characters.x" use "XDest<Characters.x + 2" (2 or 4 or whatever works)

then set the Xdest to Characters.x


It didn't work...
But this gave me an idea, maybe it is the way the function works... perhaps I should use a "while"? I'm gonna try some new ideas.

But, does anyone know how to disable the pixel interpolation for the movement, so the smallest distance it can travel and detects at the time is 1pixel ?
B
6
S
1
G
2
Posts: 26
Reputation: 1,477

Post » Mon Nov 02, 2015 11:46 am

I had this one lying around, might help:

Smooth grid movement
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Nov 02, 2015 1:32 pm

@littleStain
Really neat example. And the CPU utilization is like 40% less than my code...
B
6
S
1
G
2
Posts: 26
Reputation: 1,477

Post » Tue Jan 26, 2016 9:34 pm

@LittleStain - Ok I know you've been hit with this one a lot and I appreciate your time so I'll be quick. How do I make it so the green block can only move once then stop, and then the AI Let's say a purple block takes a turn moving toward the green block position and stop. So the other one cannot move until after the other ones turn. How do I make the AI block do this on it's own?

Group activate and then deactivate maybe? Is it possible?

Thanks
Check out my latest game RAPID-TAPIT. Get your Fingercise on with this one. A steady Tap is all you need to score points. Lift a finger and see what you can do...

Image

ALLMarkMade Designs
B
32
S
15
G
3
Posts: 356
Reputation: 5,269

Post » Tue Jan 26, 2016 9:59 pm

ALLMarkMade wrote:@LittleStain - Ok I know you've been hit with this one a lot and I appreciate your time so I'll be quick. How do I make it so the green block can only move once then stop, and then the AI Let's say a purple block takes a turn moving toward the green block position and stop. So the other one cannot move until after the other ones turn. How do I make the AI block do this on it's own?

Group activate and then deactivate maybe? Is it possible?

Thanks


shouldn't be that hard..

To create the turns you'd need a switching global variable..
Based on who's turn it is either the player would move or the enemy..

you could have the enemy find the path to the player using pathfinding (without diagonals) and have it move in the same way as the player..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Jan 26, 2016 10:23 pm

@LittleStain

switching global variable - Hmmmm I'm not familiar with that I tried a groups with a variable set to 0 group deactivated and 1 group activated. The AI path finding I understand but I can't seem to make either only go one space and stop. I'm using your example as a guide.

Thanks for your time though.
Check out my latest game RAPID-TAPIT. Get your Fingercise on with this one. A steady Tap is all you need to score points. Lift a finger and see what you can do...

Image

ALLMarkMade Designs
B
32
S
15
G
3
Posts: 356
Reputation: 5,269

Post » Tue Jan 26, 2016 10:40 pm

like I said you shouldn't use the pathfinding for the movement..

on path found just make the enemy move one spot in the direction of the first node of the pathfinding..
So every time the enemy has his turn, first use pathfinding to find the path to the player, than use the grid movement to move 1 square..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot], leandrogenske, R0J0hound, TylerJS and 8 guests