How The Heck Do You Create An Object With Collision #10
Replies: 1 comment 1 reply
-
Don't think of the Before I continue, though: It's generally not a good idea to modify variables via object reference. This: instance_create_depth(x, y, depth - 1, PlayerSlash)
PlayerSlash.source = id; ... should probably look like this instead: var slash = instance_create_depth(x, y, depth - 1, PlayerSlash);
slash.source = id; ... or alternatively: instance_create_depth(x, y, depth - 1, PlayerSlash, { source : id }); Anyways, let's take the code you have for handling enemy collision: if (place_meeting(x, y, PlayerSlash))
{
game_pc_react_to(id, other.id);
} Instead, in the Step Event of with (Enemy) {
if (place_meeting(x, y, other)) {
// run code for attacking enemy
// eg. game_pc_play_sound(source, PopSound);
}
} Hope that helps! |
Beta Was this translation helpful? Give feedback.
-
I'm trying to create a hitbox that the player can use to attack objects, right?
And here's the step event for the object. It follows Sonic. It works and it makes me smile. (By the way, I do know there's a smoother way if you use the local_direction variable,)
But I've been messing with the Monitor and Enemy create events and it does sorta work,
but no matter what I do, the objects only get destroyed within a specific distance rather than wherever I set the PlayerSlash's distance from Sonic to be. I've been at this for 2 hours reading the code and I just don't understand what's going on. I've switched the x and y variables to be other.x and other.y but still nothing changed. I know that this engine is not using gamemaker sprite collision masks, but I thought using them anyway would still work. I still read through the PCReaction function, the game_pc_in_shape function, but I still don't get it.
Could you tell me how to create an object with collision within this engine?
This probably seems really stupid.
Beta Was this translation helpful? Give feedback.
All reactions