Grid Movement behavior and Solid objects

For questions about using Classic.

Post » Thu Sep 10, 2009 3:59 pm

Hello.

I make an enemy, which must be controlled by the computer AI. The sprite has Grid movement behavior, Movement is NPC. Using conditions I set that it must move randomly in the scene (in horizontal and vertical directions).

Question is : how to make that object with Grid movement behavior collides with other objects with Solid attribute? For example, our object moves to the right and collides with the wall sprite (Solid), it stops, and randomly it continues to move to the top of the bottom along the wall. Because now it moves through the solid objects.

Thanks.
B
2
G
3
Posts: 30
Reputation: 910

Post » Thu Sep 10, 2009 4:50 pm

+Does NOT overlap SOLID at (Grid size) pixels
> Go ahead
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Thu Sep 10, 2009 5:02 pm

[quote="Mipey":33ayjpqe]+Does NOT overlap SOLID at (Grid size) pixels
> Go ahead[/quote:33ayjpqe]

It doesn't work, because the object collides with the wall and stop moving.
B
2
G
3
Posts: 30
Reputation: 910

Post » Thu Sep 10, 2009 7:17 pm

Well, the idea is to check for obstacle before moving. Before you move right, check if there is a wall (overlap at offset by number of pixels that match the grid size), if there is, don't go there and check other directions.

I hope that helps!
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Thu Sep 10, 2009 9:40 pm

Another event like [u:19y4ugi9]is[/u:19y4ugi9] overlapping at offset set vertical movement... blah, blah, blah.
Perhaps with a random chance of going either positive y, or negative.
Image Image
B
161
S
48
G
89
Posts: 7,347
Reputation: 66,249


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests