Pixel-precise custom movement on a grid.

Get help using Construct 2

Post » Sat Jan 07, 2012 2:16 am

Oh wow, I really should go to bed. Indeed, wrong bug.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Sat Jan 07, 2012 3:02 am

@Wronghands
If you use the mouse, you pretty much have no choice but to use a pathfinder.
A pathfinder will return all the cell you have to go through to reach the cell you clicked on (if it is reachable).
Then, the grid movement I coded won't be used at all. You won't need to check for collision and you will just have to interpolate between each coordinate returned by the pathfinder.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Thu May 24, 2012 9:28 pm

@Yann Thanks for writing and sharing your example! Hopefully someday there will be some grid-movement behavior or action that is part of the Construct 2 core. In the meantime, I've written something similar using the bullet behavior to automate the calculation of the new X and Y coordinates during the movement of the sprite. If you're interested, check it out at http://www.scirra.com/tutorials/308/cloning-the-classics-pacman
B
61
S
18
G
14
Posts: 50
Reputation: 18,582

Post » Fri May 25, 2012 4:59 pm

@stemkoski
nifty indeed (:
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Tue Aug 07, 2012 11:36 pm

[QUOTE=Yann] http://dl.dropbox.com/u/23551572/C2/gridMovement.capx[/QUOTE]

With this (otherwise perfect for me) script you are able to move through walls occasionally.

If the speed is lower than 256, the player can move through walls easily, but even at 256 the player can still move through walls. Is it possible to make the collision detector always position itself before the player moves to it?

I hate to bump the topic, but I have a sticking point in my game because I do not want there to be a bug where player can run through walls, and I need grid based smooth movement.

If you turn on the visibility of the green sprite, collision detector, you can plainly see how the character moves faster than the detector sprite allowing you to at times enter the collision object (wall). Is there any work around for this?

It's easier to reproduce if you lower the speed variable, but even at 256 you can still at times move through walls.

Greg2012-08-10 01:27:03
B
9
Posts: 59
Reputation: 997

Post » Sat Aug 11, 2012 1:12 pm

@Greg
There's no such bug on my side, I used this system in tones of different situations (including patroling AI) and never had any issue even at super high speed.

Do you get this bug in the original capx, or in a modified version of yours?
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sat Aug 11, 2012 10:14 pm

Thank you for the response, I really appreciate you taking the time to look into this!

The original capx can have the issue but it is very difficult to get it to go into a wall. I download it and playtest for a few minutes and can run into the wall after trying for a few minutes (moving along a wall and turning towards it constantly). Not always or easily, but it is possible.

If you turn the speed down the collision detector lags behind the player more noticeably. Setting the speed to 128 and stepping to 0 makes it much easier to run through walls. It's unfortunate because 256+ is too fast for my needs, I want a classic looking slow grid movement :(

I really like the script, so didn't want to use anything different, and I've built other scripts that rely on this script to work. I will keep looking into it, but I am no programmer lol!
Greg2012-08-11 22:22:03
B
9
Posts: 59
Reputation: 997

Post » Sun Aug 12, 2012 12:51 am

@Greg
What C2 release are you using? The logic of the capx is sound, the wall detector is doing exactly what it is designed to do: it checks the next grid position before moving. The position lag is not the issue.
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Sun Aug 12, 2012 10:04 am

I am using r99. I noticed the issue initially on r96, but never reported it because I wanted to try and get it fixed without begging for help on the forums.

I think the issue is related to lowering the stepping below 0.1 is the cause of "lag" on the collision detector. 128 speed with 0 stepping makes it easy to see.

Thank you for taking an interest and looking into it!
B
9
Posts: 59
Reputation: 997

Post » Sun Aug 12, 2012 5:38 pm

I don't think it's a problem with the events. I have not been able to move into the walls.

What browser are you using to test?
It's flawless for me in Firefox 14.0.1 and Chrome 20.0.1132.47.
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 21 guests