# [Request] One Point Collision

Discussion and feedback on Construct 2

### » Thu May 23, 2013 12:39 am

I was thinking we could need one point collision which is designed to RTS, Puzzle and game uses a lot of objects. One point collision is related to origin point.

We can't have less than 3 collision poly points, currently this method could affect the performance.

Technically, a point of collision equals the distance from other objects, adjust the distance depends on intended according to sprite size or variable defines the numbers could do trigger. Applies to all objects with this option.
B
99
S
35
G
29
Posts: 3,139
Reputation: 28,426

### » Thu May 23, 2013 12:43 am

Good point! ...

+1
As long as I can move left, right and fire, I'm Happy...
B
42
S
15
G
11
Posts: 655
Reputation: 12,270

### » Thu May 23, 2013 4:44 pm

How much does it affect performance?
B
53
S
16
G
10
Posts: 1,098
Reputation: 11,782

### » Thu May 23, 2013 5:05 pm

Could this not be done using disabled collisions and distance expression?
B
160
S
69
G
44
Posts: 2,613
Reputation: 36,857

### » Thu May 23, 2013 5:20 pm

What we need is a sprite condition like "is (x,y) in collision polygon of object A" or a system condition like "is (x,y) solid".
B
81
S
33
G
27
Posts: 1,029
Reputation: 21,143

### » Thu May 23, 2013 5:24 pm

You can disable collisions and start checking the distance between objects.

That's how I did the collision system of Golden Lotus.
B
110
S
24
G
18
Posts: 1,391
Reputation: 23,017

### » Thu May 23, 2013 8:43 pm

For performance C2 would be better off with a anything but a bruteforce collision detection. There is

Binary Space Tree
Qaud Space Tree
and Oct Space tree

the idea is to put objects into a sorted branching tree. Only when 2 objects are using the same space/branch would there even be a collision check possible. In this model if the system wanted to compare bullet against enemy. it would check to see if bullet is in the same tree branch. if "no" there is nothing to further check against.

Where as the current model. the bullet needs to check against every enemy. even if the enemy is on the other side of the screen or map.
jayderyu2013-05-23 20:57:09
B
94
S
18
G
9
Posts: 2,457
Reputation: 15,187

### » Sun May 26, 2013 10:04 am

I would like to know is possible to do with C2Joannesalfa2013-05-26 10:04:50
B
99
S
35
G
29
Posts: 3,139
Reputation: 28,426

### » Sun May 26, 2013 11:22 am

disable collisions and check position or distance, and if your game is tile based, you can use an array instead.
B
32
S
7
G
2
Posts: 164
Reputation: 3,774

### » Sun May 26, 2013 6:12 pm

@Joannesalfa
Implementing a quadtree into C2 wouldn't be that hard; especially as there is an API ready to be turned into a behaviour. The down side is that like C2 Physics which is Box2D, it's an entirely different collision check.

This means that like the Platform/Solid/Jumpthru/Bullet behaviours this Quadtree would not be compatible :( You couldn't take advantage of say Bullet Bounce off wall, and use Solid. Those are built to work together. Where as Bullet and Physics won't.

However, if you don't need Platform and Jumpthru. It can be created and implemented to good effect. The best solution is for Ashley to implement a quadtree into the natural behaviours. Might even be possible to slip it right into the basic object collision making the overhead minimal. Maybe next time there is a poll we should suggest it :)

But in the mean time maybe someone or myself if given the time can look into a behaviour.

So I tried the demo. One of the options is 500 objects. In a brute force model wich C2 uses. That would be 252,000 = 500 x 504 (+4 for walls). That's a lot of collision checks. Where as in this it looks like maybe 200-500 checks or something like that. Certainly not 200k+
B
94
S
18
G
9
Posts: 2,457
Reputation: 15,187

Next