How do I Collisions

Get help using Construct 2

Post » Mon May 25, 2015 12:17 am

Hello lurkers,

I'm trying to spawn a rectangle collision box and set it to an enemy position as they are spawned. How do i make multiple instances of the same collision object, and have each enemy only able to collide with its own said box?

I can think of ways but they aren't so efficient.

Thanks for any thoughts.
B
9
S
3
Posts: 104
Reputation: 1,033

Post » Mon May 25, 2015 2:47 am

If you can think of ways to do this, you should give them a try before blowing them off as inefficient. I'd suggest posting your solutions here, and we can let you know how/if they can be improved.
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,126

Post » Mon May 25, 2015 3:20 am

Are you looking to put a collision checker at the spawn location of each enemy to check if the enemy is 'at home'? You can easily do that using Containers and some instance variables. Like On Create Collisoin_Checker, set Collision_Checker.Enemy_UID to Enemy.UID. Then you need to decide whether to use On Collision or Is Overlapping; search the forum for discussions about efficiency and workload associated with each of those options - it depends on what you're really after as to which will be best to use. If On Collision is too demanding (lots of enemies) then you could do a distance check or, alternatively, manage their movement using a FSM so you just know when they are in collision with their start point Collision_Checker. As said above, it's hard to effectively guess what sort of help you need.
A big fan of JavaScript.
B
76
S
20
G
74
Posts: 2,255
Reputation: 46,484

Post » Mon May 25, 2015 8:44 am

Thanks for the replies, and sorry about the clarity i was half asleep.

What i need to do is find a way for an enemy to not fall off the screen when physics is enabled. However, i am unable to create any sort of static floor. Instead, what i have done, is create a rectangle object and tell it to follow Enemy position.

I imagine having 30 different rectangle objects, set to a position every tick, and telling them not to collide with each other probably isn't the best way to go about doing it.

An alternative would be to have it so the enemies only have force applied on the X axis, No idea how to go about doing that, I couldn't find much info on the physics.

Cheers.
B
9
S
3
Posts: 104
Reputation: 1,033

Post » Mon May 25, 2015 8:54 am

To create static objects you can set immovable to yes in the physics properties..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon May 25, 2015 8:57 am

Would i still be apply force to them on the X axis with a projectile, if they are set to immovable?

thanks mate
B
9
S
3
Posts: 104
Reputation: 1,033

Post » Mon May 25, 2015 9:04 am

I guess I don't understand your question.
You said you wanted a static floor?
Set it to immovable.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon May 25, 2015 9:29 am

Sorry, I didn't want a static floor. I'm looking for a way so that the enemies stay on their current Y position when hit with an arrow, but still be able to move along the X (as if they are sliding along an invisible floor).

I might just be bad at explaining lol, no wonder the computer cant understand me.
B
9
S
3
Posts: 104
Reputation: 1,033

Post » Mon May 25, 2015 9:37 am

Ok..
so why are you using physics for this, when you don't want the enemies to have physics behaviour?

There are many ways around this, but you might first want to be sure the behaviour you are using is what you need..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon May 25, 2015 9:55 am

That is why i was asking if anyone knows a better way to do what im trying to achieve. Ive been at this for just over a week so forgive me if im using the wrong methods.

I just presumed physics was the way to go, as i want to create the sliding illusion with friction and density etc. (Different enemies will appear heavier and take less force from projectiles)

Im open to any suggestions. As i said, i do not think i am doing it correctly.
B
9
S
3
Posts: 104
Reputation: 1,033

Next

Return to How do I....?

Who is online

Users browsing this forum: tarek2 and 22 guests