Jump to content


Photo

Go through floor for only certain objects


  • Please log in to reply
10 replies to this topic

#1 _257502

_257502

    GMC Member

  • GMC Member
  • 98 posts
  • Version:Mac

Posted 21 April 2012 - 05:41 AM

I am working on a megaman game and I am trying to make a gravity gun, normally the enemy telly will fly through the floor. But when its shot with the gravity gun I want it to bounce towards megaman. So I tried to use solid for the floor value but that made it so if the enemy came from under megaman he would go through the floor and sometimes the telly would get stuck if he was touching multiple floor objects. I need the telly to be able to fly through the floor but not effect megaman going through when the variable grav=0 and bounce when grav=1 but i've been doing this for hours and whenever i put in a collision check event on the telly he automatically acts as a solid and gets stuck.

Edited by _257502, 13 July 2012 - 08:34 PM.

  • 0

#2 _257502

_257502

    GMC Member

  • GMC Member
  • 98 posts
  • Version:Mac

Posted 23 April 2012 - 02:51 AM

*Bump
  • 0

#3 _257502

_257502

    GMC Member

  • GMC Member
  • 98 posts
  • Version:Mac

Posted 23 April 2012 - 04:13 AM

Ok, apparently no one is seeing this thread but I might have solved my problem with an instance change even thought i know its a big no no its all I can think of!
  • 0

#4 integrate

integrate

    GMC Member

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 23 April 2012 - 04:48 AM

Ok, apparently no one is seeing this thread but I might have solved my problem with an instance change even thought i know its a big no no its all I can think of!

Just noticed your question for the first time. instance_change is a no-no? Oh oh, been using it for my game and love it (for certain circumstances). Wonder what it is about that function that you heard?
  • 0

#5 _257502

_257502

    GMC Member

  • GMC Member
  • 98 posts
  • Version:Mac

Posted 23 April 2012 - 06:28 PM

Just noticed your question for the first time. instance_change is a no-no? Oh oh, been using it for my game and love it (for certain circumstances). Wonder what it is about that function that you heard?


I don't remember where I heard it but in my own experience using instance codes usually cause more problems than they solve. But I tried it anyway and it completely solved my problem all I had to do was make another object with a different movement code and change to it on collision.
  • 0

#6 integrate

integrate

    GMC Member

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 23 April 2012 - 06:52 PM


Just noticed your question for the first time. instance_change is a no-no? Oh oh, been using it for my game and love it (for certain circumstances). Wonder what it is about that function that you heard?


I don't remember where I heard it but in my own experience using instance codes usually cause more problems than they solve. But I tried it anyway and it completely solved my problem all I had to do was make another object with a different movement code and change to it on collision.


Yeah, I like using instance_change. It seems to me however that an instance_destroy of current object and instance_create of new object may do the same thing. I'm sure there's more to experiment with here.
  • 0

#7 _257502

_257502

    GMC Member

  • GMC Member
  • 98 posts
  • Version:Mac

Posted 24 April 2012 - 04:20 AM

Yeah, I like using instance_change. It seems to me however that an instance_destroy of current object and instance_create of new object may do the same thing. I'm sure there's more to experiment with here.


Yeah it does the same thing, either way caused a death animation i had to happen when i changed instances. So I needed to add a health variable to cause the destroy event not to trigger but it seems to work perfect now!
  • 0

#8 integrate

integrate

    GMC Member

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 24 April 2012 - 07:31 AM

Yeah it does the same thing, either way caused a death animation i had to happen when i changed instances. So I needed to add a health variable to cause the destroy event not to trigger but it seems to work perfect now!


It works perfect with destroy and create, or just change?
  • 0

#9 decroded

decroded

    GMC Member

  • GMC Member
  • 572 posts
  • Version:GM8

Posted 24 April 2012 - 09:07 AM



Yeah, I like using instance_change. It seems to me however that an instance_destroy of current object and instance_create of new object may do the same thing. I'm sure there's more to experiment with here.


Yeah it does the same thing, either way caused a death animation i had to happen when i changed instances. So I needed to add a health variable to cause the destroy event not to trigger but it seems to work perfect now!

Just a tip, you can just check the hp var in destroy event to check if the object was actually killed by the player.
If it was destroyed by the system then the hp would still be > 0 so no need to play the death animation and sounds...
  • 0

#10 _257502

_257502

    GMC Member

  • GMC Member
  • 98 posts
  • Version:Mac

Posted 24 April 2012 - 04:20 PM

Did the change and it works fine, its less code to do and as far as the hp variable I did that its just weird that when you do a change it actually triggers the destroy event to instead of just replacing it.
  • 0

#11 decroded

decroded

    GMC Member

  • GMC Member
  • 572 posts
  • Version:GM8

Posted 25 April 2012 - 12:59 AM

Did the change and it works fine, its less code to do and as far as the hp variable I did that its just weird that when you do a change it actually triggers the destroy event to instead of just replacing it.

What I mean was for example...

In obj_monster's Destroy event:
var anim;
if hp <= 0 //--actually killed by attacks rather than the system
{
    sound_play(snd_monster_aarrgh);
    //--a cheap way to play the death animation after instance is destroyed:
    anim=instance_create(obj_anim);
    anim.sprite_index=spr_monster_death;
}

In obj_anim's Animation End event (under Other):
instance_destroy();

This won't trigger the death event (just don't a trigger) unless you have something else going on.
The code to destroy the monster should be either at time of attack or you can dump a health-check in step or something...
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users