Jump to content


Photo

Too Many Collision Events


  • Please log in to reply
8 replies to this topic

#1 Ercle

Ercle

    GMC Member

  • New Member
  • 6 posts

Posted 07 October 2009 - 09:57 PM

In the game I am making there are a redundacy of collision events for one object and I need a unified script to put all of the collision events together as one. Thank you.
  • 0

#2 Dangerous_Dave

Dangerous_Dave

    GMC Member

  • Global Moderators
  • 9276 posts
  • Version:Unknown

Posted 07 October 2009 - 10:02 PM

If the collision events are all the same but for different objects, you could create a new object and set this as the parent object of the others, then just check collisions against the parent object.
  • 0

#3 Izkhanilov

Izkhanilov

    GMC Member

  • GMC Member
  • 209 posts

Posted 07 October 2009 - 10:06 PM

I tried this, but it deleted all the instances as the game start, but maybe it'll spark some ideas.

Step event:
if
place_meeting(x,y,obj1)
place_meeting(x,y,obj2)
etc,
etc,
etc,
instance_destroy();

  • 0

#4 drt_t1gg3r

drt_t1gg3r

    GMC Member

  • GMC Member
  • 3230 posts
  • Version:Unknown

Posted 07 October 2009 - 10:12 PM

In the game I am making there are a redundacy of collision events for one object and I need a unified script to put all of the collision events together as one. Thank you.

uhm take out the redundancy.
unless timing is the problem there is no need to have multiple collision checks for one item. just put all the code under one collision check. with the use of blocks you take out all the redunancy
  • 0

#5 Ercle

Ercle

    GMC Member

  • New Member
  • 6 posts

Posted 07 October 2009 - 10:18 PM

In the game I am making there are a redundacy of collision events for one object and I need a unified script to put all of the collision events together as one. Thank you.

uhm take out the redundancy.
unless timing is the problem there is no need to have multiple collision checks for one item. just put all the code under one collision check. with the use of blocks you take out all the redunancy

I don't have multiple collision events for one object, I just have many objects with the same collision event.
  • 0

#6 Izkhanilov

Izkhanilov

    GMC Member

  • GMC Member
  • 209 posts

Posted 07 October 2009 - 10:19 PM

In the game I am making there are a redundacy of collision events for one object and I need a unified script to put all of the collision events together as one. Thank you.

uhm take out the redundancy.
unless timing is the problem there is no need to have multiple collision checks for one item. just put all the code under one collision check. with the use of blocks you take out all the redunancy

I think he means that in one object there are many objects which when collided with achieve the same thing.
  • 0

#7 Obj_Control

Obj_Control

    GM Mentor

  • New Member
  • 2561 posts

Posted 07 October 2009 - 10:22 PM

Do as Dave said.

Make an object called obj_block_parent or whatnot, and set it as the parent of every object that is subject to the collision event.
  • 0

#8 jabelar

jabelar

    GMC Member

  • New Member
  • 2980 posts

Posted 07 October 2009 - 11:43 PM

Definitely use parents. If all your enemies get destroyed by a laser, then you can just process the collision with the laser beam object and the enemy parent. Even if they are not all the same result (like maybe each enemy has different points to add to score) you can make it generic with some variables. So in the Create event for each specific enemy object, I'll make a variable called worth set to their point score. But all the enemies have a parent called objParentEnemy. Then when laser object collides with objParentEnemy I can just add other.worth to the score.

I think it is also better programming practice to only use Step event and trap collisions there. For example, just use a bunch of collision checkings statements in the Step event that call related processing scripts like:

if place_meeting(x, y, objParentEnemy) then scriptProcessCollisionEnemy();
if place_meeting(x, y, objParentCoin) then scriptProcessCollisionCoin();
// etc ...

  • 0

#9 drt_t1gg3r

drt_t1gg3r

    GMC Member

  • GMC Member
  • 3230 posts
  • Version:Unknown

Posted 08 October 2009 - 12:18 AM

In the game I am making there are a redundacy of collision events for one object and I need a unified script to put all of the collision events together as one. Thank you.

uhm take out the redundancy.
unless timing is the problem there is no need to have multiple collision checks for one item. just put all the code under one collision check. with the use of blocks you take out all the redunancy

I don't have multiple collision events for one object, I just have many objects with the same collision event.

make a script that they all share and just call the one script in all of their collision events
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users