How do I Collisions

0 favourites
  • 12 posts
From the Asset Store
Particles support animations, collisions, effects and etc.
  • 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.

  • 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.

  • 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.

  • 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.

  • To create static objects you can set immovable to yes in the physics properties..

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

    thanks mate

  • I guess I don't understand your question.

    You said you wanted a static floor?

    Set it to immovable.

  • 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.

  • 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..

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I've not seen your project, so I have no idea what you are actually trying to achieve..

    Programming is all about creating illusions..

    You could just move the enemy for a certain amount of time while slowing it down after it has been hit by a projectile..

    It would look and feel the same to the player, but wouldn't make use of physics.

    It would also give you a lot more control over the actual speed, and time and distance moved..

  • Thanks, ill give it a go without using the physics.

    For future reference, how should i upload my project?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)