How do I stop sprites overlapping

Get help using Construct 2

Post » Wed Jun 18, 2014 9:46 am

lolpaca wrote:Cool, I'll have a play around with that later. Does the invisible sprite also need to have the main movement routines (eg I'm currently using MoveTo + Line of Sight to chase the player when they can see him), or can you assign those to the main sprite, and just leave the pinned invisible ones as Custom Movement with Solid enabled and it'll work itself out?

My main problem in the past has been the way sprites sort of 'pop' around the place when pushing out of solids, especially when clumped - it just looks glitchy and bad. A lot of my game is also in very tight tunnels which makes it doubly hard to find something that works.


No, use pin behavior and pin barrier box on start of layout to enemy.
Try widening your collision polygon. Open sprite edit and bottom left is lots of dots, drag them out to widest points, try to make circle round sprite this is the barrier for solid. See how that looks before adding invisible sprite, make sprite image bigger (the clear space) and widen the circle till it looks about right... see if that works. I say circle because square will give that bumping look when colliding. circle rolls around nicely.

Edit: monitz87 answered above perfectly, but try and play around with collision polygon first, see how it looks
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,708

Post » Wed Jun 18, 2014 5:59 pm

This doesn't seem to work, at least not with the MoveTo behaviour - the enemies still just run right through each other. I could try and do it through CustomMovement instead, does that definitely work?
B
15
S
4
G
1
Posts: 286
Reputation: 1,988

Post » Wed Jun 18, 2014 6:27 pm

Did you adjust your collision polygon? did you give it enough space? Are you using solid behavior?

Else, the other way works well, just a little more complicated. If you post a demo capx with behaviours set up and moveto (basically having enemies chacing hero) this will save time in creating a moch up and I will try and put a "force field around them" lol. Its night here now so will try tomorrow sometime.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,708

Post » Thu Jun 19, 2014 2:35 am

Solid behavior or Pinning an invisible sprite to the player or change the angle of the player if it collides.

Post your capx. Let us see whats going on.
Image
B
31
S
7
Posts: 197
Reputation: 2,497

Post » Thu Jun 19, 2014 5:04 am

lolpaca wrote:This doesn't seem to work, at least not with the MoveTo behaviour - the enemies still just run right through each other. I could try and do it through CustomMovement instead, does that definitely work?


I think we need more information. What exactly "doesn't work"? Which solution did you implement and how? AFAIK, you can change the target coordinates of MoveTo dynamically, so if the event which makes enemies follow the player is a base level event, you should just adjust the MoveTo target every time the force fields collide with each other.

HOW you should adjust them depends on the AI you want to implement, but a simple suggestion would be to make them move in an arc using the player as the circle's center (the angle of the arc would be an inverse function of the distance between the player and the enemy, so if two enemies 'get too close' far away from the player, they just step aside and keep marching towards the player, but if the 'getting too close' is closer to the player, you get a bigger arc and so the enemies seem too surround the player)
B
6
S
2
Posts: 79
Reputation: 608

Post » Thu Jun 19, 2014 6:30 am

There are so many ways to achieve same results. And they all work ;)
I Agree with monitz87 and harishankar, post a capx lets get to the bottom of this :)
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,708

Post » Thu Jun 19, 2014 8:27 am

Cheers guys, my capx is a bit of an unholy mess at the moment but I'll try to mock up something like what I want to achieve and post it up soon. I did manage to get something sort of working with solids, but as before - and even with the refined collision boxes - they glitched around a lot when they clumped up, and sometimes jumped through walls in the tunnels, which isn't ideal!

Actually I got sort of halfway there with a combination of MoveTo and the Boids flocking behaviours. The mobs chase and keep a good distance from one another without glitching - now I just need to figure out a way to get them to navigate around obstacles.

@monitz87 your solution sounds interesting, I'll definitely give that a go too. I must admit half the functions in MoveTo are a bit of a mystery to me, I just use it as a lazy man's shortcut to something I'd usually do with Custom Movement!
B
15
S
4
G
1
Posts: 286
Reputation: 1,988

Post » Thu Jun 19, 2014 9:11 am

lolpaca wrote:Cheers guys, my capx is a bit of an unholy mess at the moment but I'll try to mock up something like what I want to achieve and post it up soon. I did manage to get something sort of working with solids, but as before - and even with the refined collision boxes - they glitched around a lot when they clumped up, and sometimes jumped through walls in the tunnels, which isn't ideal!

Actually I got sort of halfway there with a combination of MoveTo and the Boids flocking behaviours. The mobs chase and keep a good distance from one another without glitching - now I just need to figure out a way to get them to navigate around obstacles.

@monitz87 your solution sounds interesting, I'll definitely give that a go too. I must admit half the functions in MoveTo are a bit of a mystery to me, I just use it as a lazy man's shortcut to something I'd usually do with Custom Movement!


Have you had a look at pathfinding? I'm not very good with it.
Great examples shipped with C2 - its my go to resource ;) from pathfinding to multiplayer.
Open C2. Click 'New' and scroll down that page.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,708

Post » Thu Jun 19, 2014 9:41 am

Pathfinding's not really an option for my project unfortunately, as so much of the terrain is destructible it requires frequent regeneration of the obstacle map, which causes stutters - unless there is some more efficient way to do it that I don't know about. Otherwise it'd be ideal.

EDIT - This is my project by the way, you can see what I mean about the tunnels and obstacles. If you make it to the boss room, he spawns skeletons, which use the Boids/MoveTo combination I described above. However, the boss room's a big open space with no obstacles. I'll keep chipping away at it though, there must be a solution!

https://dl.dropboxusercontent.com/u/106 ... index.html
B
15
S
4
G
1
Posts: 286
Reputation: 1,988

Post » Thu Sep 18, 2014 10:35 pm

It's been several months since you asked, but I've had good results by making a particular object part of a family; even if it's the only one object type.

This gives you the ability to test collisions/overlap for different instances of the same sprite object. The how can be achieved through different approaches to the logic, but it essentially begins from:

01 Dude | is overlapping DudeFamily
02 X Pick DudeFamily by Unique ID| Dude.UID <-----inverted from sprite conditions or you can evaluate the instance UID (as in UID <> UID ) via system conditions

From this point you have many options, whether you test to see if one is moving faster, or at a particular angle, or pick a random instance picked from the aforementioned conditions; and then apply an every tick condition that moves or rotates one or both sprites with frame-rate independent action.

The suggestions above regarding an invisible collision-detection sprite work too and you do not have to give it solid behavior--just trigger an event that properly picks the instances and then test some different frame-rate independent actions that correspond to the trigger. This is where our old, wretched friends cos/acos, tan/atan and sin/asin can help provide more accurate behaviors in groups of sprites.

Jason
B
8
S
2
Posts: 9
Reputation: 1,809

Previous

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 2 guests