GameMaker Finding the Exact Collision Point Between 2 Objects

Wendell

Member
Hey guys, needing some help. How can I find the exact collision point between the fire object and the wall object? Both are separate objects and I want to make some animation on that point when the fire touches the wall. The fire rotates every step. I tried to use place_meeting and instance_place variations, but no success. Thank you in advance.

 

Wendell

Member
Your fire is pretty line-y, so you could use this script I did some time ago https://yal.cc/gamemaker-collision-line-point/
Wow, thank you! I'm trying to add this to my project, but I'm not being successful.

I've added it to the fire object, but whenever it touches the wall the error "trying to index a variable which is not an array" appears.

Not sure if I made correctly (new to GML):

Code:
var r = scrCollisionLinePoint(x, y, x, y, oMetal, true, true);
if (r[0] != noone) {
instance_create_layer(x, y,"InstancesFront",oEnCollideWall);
}
I want to create the "oEnCollideWall" on the collision between the fire and the oMetal object.
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
Wow, thank you! I'm trying to add this to my project, but I'm not being successful.

I've added it to the fire object, but whenever it touches the wall the error "trying to index a variable which is not an array" appears.

Not sure if I made correctly (new to GML):

Code:
var r = scrCollisionLinePoint(x, y, x, y, oMetal, true, true);
if (r[0] != noone) {
instance_create_layer(x, y,"InstancesFront",oEnCollideWall);
}
I want to create the "oEnCollideWall" on the collision between the fire and the oMetal object.
What GameMaker version are you using?
 

Wendell

Member
What GameMaker version are you using?
Using Game Maker Studio 2.

Forgot to mention that the error indicates the line "if (r[0] != noone)"

Tried to add instance_create_layer(r[1], r[2],"InstancesFront",oEnCollideWall) but it does not work as well.

Thank you, really appreciate your help

Edit: @YellowAfterlife not sure what I did but there's no error anymore, however, the object is not created on the collision between the fire and the wall/metal object. I'm trying this:

Code:
var r = scrCollisionLinePoint(x, y, x, y, oMetal, true, true);
if (r[0] != noone) {
instance_create_layer(r[1], r[2],"InstancesFront",oEnCollideWall);
}
 
Last edited:

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
Using Game Maker Studio 2.

Forgot to mention that the error indicates the line "if (r[0] != noone)"

Tried to add instance_create_layer(r[1], r[2],"InstancesFront",oEnCollideWall) but it does not work as well.

Thank you, really appreciate your help
And did you paste the script contents (starting with /// and ending at return r) into your scrCollisionLinePoint?
 

Wendell

Member
And did you paste the script contents (starting with /// and ending at return r) into your scrCollisionLinePoint?
Yes sire, double checked it. Not sure what I just did now but there's no error anymore, however, the object is not created on the collision between the fire and the wall/metal object. I'm trying this:

Code:
var r = scrCollisionLinePoint(x, y, x, y, oMetal, true, true);
if (r[0] != noone) {
instance_create_layer(r[1], r[2],"InstancesFront",oEnCollideWall);
}
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
Yes sire, double checked it. Not sure what I just did now but there's no error anymore, however, the object is not created on the collision between the fire and the wall/metal object. I'm trying this:

Code:
var r = scrCollisionLinePoint(x, y, x, y, oMetal, true, true);
if (r[0] != noone) {
instance_create_layer(r[1], r[2],"InstancesFront",oEnCollideWall);
}
Okay then. Your next problem is that you are checking for collision from point to the same point rather than from XY to wherever offset in direction
 
Top