SOLVED Missing something Simple?

M

Malico

Guest
Hey there, I'm trying to get a collision from a bullet to set code on the object it collides with to trigger a smash portion of code.

The collision check runs and destroys the bullet, but the smash variable is not updated on the target. (crate is temporary target for testing)

Seems the other constant is not recognised even during the collision.

Any ideas?

Much appreciated.

Code from Bullet Step:

GML:
if place_meeting(self.x,self.y,obj_crate) // Hit target
{
    other.smash = 1;
    other.hit_dir = direction + irandom_range(-10,10);
    other.hit_spd = speed+irandom_range(1,5);
   
    instance_destroy(); // This works (bullet destroys)
}
Code to trigger on obj_crate:

GML:
if smash = 1
{  
    part_1 = instance_create_depth(self.x,self.y,8,obj_crate_smash_1);  
    part_1.direction = hit_dir;
    part_1.speed = hit_spd;
   
    instance_destroy();  
   
}
 
M

Malico

Guest
How have you defined other here? It's not a collision event, and it doesn't appear to be inside a with.
from what I can tell, other is a constant variable that ties to teh collesion event as GMS deals with collisions on a 1v1 basis, other cannot be defined as it will cause a compile error

Due to there being multiple breakable items I cannot do a with crate { } as it will break all of them
 

Nidoking

Member
from what I can tell, other is a constant variable that ties to teh collesion event
Yes, and as I said, this is not in a collision event, because you said that it's in the step event. So you can't use other. You will need to get the instance ID of the specific crate. Might I suggest instance_place rather than place_meeting?
 
M

Malico

Guest
Yes, and as I said, this is not in a collision event, because you said that it's in the step event. So you can't use other. You will need to get the instance ID of the specific crate. Might I suggest instance_place rather than place_meeting?
Oh ok that makes sense, I'll give it a shot and let you know! -- Does instance place pull the instance ID at that location? I'm still learning a lot of the functions as I go

I've always used step event for collisions or maybe just position references such as mouse over ui buttons and wall / border collisions with no issues
 
M

Malico

Guest
Got it to work :D I moved the step code to a collision > Parent -- totally makes sence with the other constant having to pull that info! I appreciate the knowledge :)
 
Top