Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: Game Maker 7 Pro: Getting an object to do something when it collided with...  (Read 1215 times)

0 Members and 1 Guest are viewing this topic.
Game Maker 7 Pro: Getting an object to do someth...
« on: September 27, 2008, 03:35:20 am »
  • Protecting Hyrule from the forces of Darkness!
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 418
Okay here is my problem:
I have two goombas in a room with a floor and two walls made of Block objects. The block objects are solid 16x16 squares.
When a goomba hits the block the collision event goes as follows:
if(vspeed > 0 && y < y+1)
{
      move_contact(270);
      vspeed = 0;
}
This tells the goomba not to fall through the block and to turn around when it hits the block from the side.

I attempted to make the goomba object solid and add the same code to a collision event for when it hits a goomba.
When solid it appears to make one goomba get shoved up against the other one which makes it appear to disappear.
When not solid the goombas pass by eachother.

How can I get the goombas to react to a collision with what it is an instance of itself.

I tried doing and if statement to check to see if itself and the object involved in the collision are not the same id.
I tried the following code conditions:
"if(!(self.id == other.id))" and "if(!(self == other))"

and I get no change in behavior.

Any Ideas?

If someone can provide hosting I can upload the gmk file so someone could help directly.
« Last Edit: September 27, 2008, 04:13:24 am by Zentawolcotious »
Logged
My screenname is pronounced:
Zen-ta-wo-cot-ious the L is silent.
Visit Parnell Games
Quote from: MaJoRa
Be who you are and say what you feel because those who mind don't matter, and those who matter don't mind.
Quote from: Zentawolcotious
Live today as if its your last.
Re: Game Maker 7 Pro: Getting an object to do so...
« Reply #1 on: September 27, 2008, 04:30:54 am »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3374
other.id wont work, you need to call your collisions in the step event, using something like:
Code: [Select]
other = collision_rectangle(x1,y1,x2,y2,true,true)that sets the variable other to the id of the object that is collided with. the x's and y's are self explanatory, the first true is wether or not to use precise collisions, the second is to check and make sure the collided instance is not the instance calling the code.
from there you can use checks to make sure it is the right object, etc.
Logged
Quote from: Jason
Your community is a bunch of stuck up turds.

mit

Re: Game Maker 7 Pro: Getting an object to do so...
« Reply #2 on: September 27, 2008, 06:54:23 pm »
  • QBASIC programmer since age 4. Take that, world.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 1079
I'd assume it's the move_contact that's your problem.

If you want them to turn around when they collide, just have a collision with itself as changing direction, being solid shouldn't affect that. If it's not working, it might be that both of them are calling the code, and changing direction twice, or something like that.


If the worst comes to the worst, it may be worth trying to separate collisions with blocks from collisions with other gombas. Remember you can changing whether they're solid dynamically using something like with (obj_gomba) {solid=0} and changing it back at the end of the code. You'll have to experiment.
Logged
Programmer / Spriter / Level designer / Game Director / Web Designer / Music Sequencer for
Random Highscore table:

Play the Kousou Arcade today!
  • Kousou Games
Re: Game Maker 7 Pro: Getting an object to do so...
« Reply #3 on: September 28, 2008, 02:49:55 am »
  • Protecting Hyrule from the forces of Darkness!
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 418
I fixed it... long story short I coded the collision event with itself to think and determine which way to go away from the collision. Thanks for the help, however.

Edit: Ok since this is no longer needed.

*casts lock*

*thread locked*
« Last Edit: September 29, 2008, 03:52:31 pm by Zentawolcotious »
Logged
My screenname is pronounced:
Zen-ta-wo-cot-ious the L is silent.
Visit Parnell Games
Quote from: MaJoRa
Be who you are and say what you feel because those who mind don't matter, and those who matter don't mind.
Quote from: Zentawolcotious
Live today as if its your last.
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.248 seconds with 77 queries.

anything