Change size and position of circle collision

Get help using Construct 2

» Sun Feb 26, 2012 12:11 pm

Hi,

I have a problem with a sprite and its collision zone.

Here is the sprite in question:

Ideally, I'd like to use a circle as collision zone. But the collision seems to be larger than the character's body (as you can see on the picture above). Is it possible to set the circle zone size and position? (if would be... perfect)

If not possible... There could be two solutions:

- dividing the character into two parts (body and "legs") and apply the collision zone to the body, but I'd prefer to avoid that solution if possible (it creates different problems).

- use a polygon as collision zone: it could be an alternative solution but in order to be efficient and get an accurate collision, I need to add many points. I know this is not recommended to put more than 8 points but I've tried with 23 points and the game doesn't seem more laggy than previously.

Which solution(s) would you recommend?

Rag'
B
17
S
4
G
4
Posts: 137
Reputation: 3,767

» Sun Feb 26, 2012 2:48 pm

Do you mean in the Physics behavior? I would recommend using a slightly smaller invisible object with the circle collision to get the size you want. Then, every tick set the position and angle of the player to the invisible object.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

» Sun Feb 26, 2012 11:29 pm

Yeah, the Physics behavior.

That's an smart solution I've tried... but it doesn't work (more accurately: I can't make it work in my project... but yes, it would be great). I get crazy because of this...

Maybe if I describe what I want to do and what I need, someone would be able to help me. Here is the gameplay loop (unfortunaly it is an old version but you'll be able to figure out what it is about and in which context I need to have a physical objet "animated").

http://dl.dropbox.com/u/63083711/index.html

- The physical objets I mentioned are randomly generated from the bottom of the screen, every X frames.

- First, I create the physical objet. I give it an ID (taken from a enemy count... I could use the IID but it doesn't work either, I suppose the problem doesn't come from there).

- Then I spawn on it the visual aspect. I give it an ID, the same than the physical objet, in order to link both.

- I can't link the two objets :o It's a mess: the very first spawned object and its visual aspect move as they should do, and once the second physical objet is spawned, all the visual aspects just... stop and don't follow the physical objects.

Here is the code I use:

That's the way I've done with the dropped balls (it's a physical objet with a visual aspect over it), but I don't know why... in this case, it worked :o

Seriously, that's something that made me crazy for hours, maybe I've missed something obvious and stupid... but now, I don't know how to identity an objet among other similar, after having spawned them "generically". If I could master that kind of things, everything would be easier...

Rag'

PS: I may be unclear in my explanations and expectations... If so, please don't hesitate to ask questions in order to identify what's wrong. I really need to make it work Ragtime2012-02-26 23:36:16
B
17
S
4
G
4
Posts: 137
Reputation: 3,767

» Sun Feb 26, 2012 11:43 pm

(even if I'd really like to find a solution to the problem above, it would be great to set the circle collision, like it is possible with the box and polygon collisions... radius, center position etc.)Ragtime2012-02-26 23:43:16
B
17
S
4
G
4
Posts: 137
Reputation: 3,767

» Mon Feb 27, 2012 11:42 am

Ok, I think I'll create another topic relative to this specific problem, for more visibility...

But in the case I wouldn't succeed to use properly the circle collision, would it be complete heresy to make a polygon collision with ~20 points?
B
17
S
4
G
4
Posts: 137
Reputation: 3,767