Jumping slimes and collision

IFCATS

Villager
Member
Joined
Feb 3, 2020
Messages
14
Reaction score
5
First Language
Italian
Primarily Uses
RMMV
So in my game i have a switch that is triggered when an event touch the player, who loses a life and is knocked back.
It works (sort of) well but I have a problem with jumping enemies.

If a slime or whatever jump and it lands directly on the tile where the player actor is the switch is not triggered (switch is called in a event touch event). How can I solve this?

I was thinking about creating a loop that checks continuously on player coordinates and compare it with the coordinates of the enemy when it lands but I am not sure how to implement it. Maybe putting the loop that store the player coordinates as a separate parallel event and compare it in the enemy event after each jump. What do you think? It seems a bit convoluted and I am still quite new to rpgmaker so I want to avoid writing spaghetti code. Any tips/ ideas?
 

fizzly

Veteran
Veteran
Joined
Mar 23, 2012
Messages
515
Reaction score
331
First Language
Polish
Primarily Uses
RMMV
But what do you want to achieve by this? Enemy is jumping on you to attack you? "Event touch" doesnt work, because the event is on evvent, and the slime is "same as character" I think.
 

ImaginaryVillain

Creator of the greatest plugin ever!!!!!!
Veteran
Joined
Jun 22, 2019
Messages
357
Reaction score
994
First Language
Absurdism
Primarily Uses
RMMV
Set the event to parallel, then add an if statement checking for...
JavaScript:
Math.floor($gameMap.distance($gamePlayer.x, $gamePlayer.y, $gameMap.event(this._eventId).x, $gameMap.event(this._eventId).y)) === 0;
You can change the 0 to whatever distance you want to check for.
 

IFCATS

Villager
Member
Joined
Feb 3, 2020
Messages
14
Reaction score
5
First Language
Italian
Primarily Uses
RMMV
@fizzly, I am not sure what you mean. Anyway yes, the slime jumps around the map trying to hit you.

@ImaginaryVillain I'll give it a try!

Thanks for helping guys!
 

IFCATS

Villager
Member
Joined
Feb 3, 2020
Messages
14
Reaction score
5
First Language
Italian
Primarily Uses
RMMV
I could not get my head around the script so I ended up solving it like this. I'll post it here in case it could be useful for fellow javascript-impaired like me

slimechecker.PNG
slimetest is the name of the slime event jumping around to kill you.
The deleted lines are not relevant to the behaviour.
The yellow wait instead is really important to time the triggering of the hit switch with the animation and it should be adjusted accordingly.
The jumpcheck switch is turned on inside the custom route of the slime.

edit: you can have a single event checking for all the slimes, as long has each slime has its own coordinates
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

I got tired of not having an avatar image. Couldn't think of anything cool. So I'm just using my game's antagonist instead... How original. At least both of our names start with C?
Expectation: Design/dev a game for the game jam | Reality: "These codes suck, why did I do it this way? lemme fix this. Also what if I add feature xyz because... well, I can."
Did my first script call in an event! :kaopride: It's completely useless and just because I thought it'd be cute if looking at clocks in-game made the character say the real-world time, but it's fully functional scripting and I did it all by myself!
Stream will be going live shortly! I will be playing Resident Evil 3 Remake, and then I will be switching to a session of the Interactive Text Adventure! Feel free to drop by!
Spent all day working on something that ultimately has nothing "flashy" to show at the end of it. But that sense of achievement...

Forum statistics

Threads
95,632
Messages
930,567
Members
125,942
Latest member
AbigailTal
Top