Chase scenes with big sprites

SakuraMiya

Invincible Airhead
Veteran
Joined
Jul 17, 2016
Messages
76
Reaction score
3
First Language
Spanish
Primarily Uses
Is there a way to make chase scenes with very big sprites? (a la Ao Oni, but thicker, like the Caterpillar Oni). The problem is that when the sprites are so big, the event touch looks awkward when they reach the player. Is there any way to fix it, like a script or something?
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
Well, you could define a certain proximity in each one of the four directions and use that for collisions. It requires a parallel process event to check the distance each frame, but it is possible. Since I did not play Ia Ao Oni I do not know what you mean, but I am pretty sure that three different collisions (right/left + up + default) should be enough.

In general, when asking for help, you should describe exactly what you mean instead of referencing a game. That would increase the number of people that can give you an answer. That said, if you explain it with more details, we can definitely help you with this. It does not sound too complex.
 

SakuraMiya

Invincible Airhead
Veteran
Joined
Jul 17, 2016
Messages
76
Reaction score
3
First Language
Spanish
Primarily Uses
Well, you could define a certain proximity in each one of the four directions and use that for collisions. It requires a parallel process event to check the distance each frame, but it is possible. Since I did not play Ia Ao Oni I do not know what you mean, but I am pretty sure that three different collisions (right/left + up + default) should be enough.

In general, when asking for help, you should describe exactly what you mean instead of referencing a game. That would increase the number of people that can give you an answer. That said, if you explain it with more details, we can definitely help you with this. It does not sound too complex.
Sorry, it's just that I wasn't sure of the actual terms. What I want is to make a chase with a big sprite (these are referencial sprites btw) but how can I make it that when the player makes contact with the monster's head for it to be a game over? Since the sprite is big, the game over is reached when the monster's chest reaches the player.

@Heirukichi and how I'm supposed to use collisions for a chase event?
 

Attachments

Last edited:

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
From what I can see the only issue lies within horizontal collision with the player. That being the case you can do that with simple events. What you need:
  1. a parallel process event to check the virtual collision;
  2. an autorun event containing the real event commands.
Both of them can be pages of the chaser itself. The default page can be a parallel process event, while the second page can be an autorun event with a certain condition (for the sake of speaking I am going to use Self Switch A).

- - - - - - - - - - - - -​

What the parallel process is supposed to do
The parallel process event has to constantly compare the player position with the event position. If the distance is lower than or equal to a certain set distance, the Self Switch A is set to true and the autorun part starts.

You can store both your event position and your player position into variables using event commands (Control Variable) or you can use a script call. First of all decide a distance (in squares) that will determine when a collision happens (based on your image I would say two squares are enough).

To determine if the player is touching the event with a set distance of 2 it means that the difference between the player X coordinate and you event X coordinate is between -2 and 2, and the difference in their Y coordinate is within the [-1, 1] range.

To do that you need two conditional branches. If you are storing those coordinates in variables, you can simply check the variable value, if you are not, you can use the Script feature in the conditional branch command and type this
Code:
($game_map.events[your_event_id].y - $game_player.y).abs <= 1
to check y coordinates, and this
Code:
($game_map.events[your_event_id].x - $game_player.x).abs <= your_distance
to check the x coordinate.

If both of them are true, simply change the Self Switch A and set it to true. If they are not, move the event one step closer to the player.

- - - - - - - - - - - -​

What the autorun event is supposed to do
The autorun event is basically your normal event. The "Player Touch" option is emulated by the parallel process that checks the player proximity so there is no need to use it here. Simply set the page event trigger option to "Autorun" and set "Self Switch A is ON" as page condition.

The contents of this page should be the same as the contents of your normal event. Just remember that, since it is an autorun event, you have to stop it manually either by using the Erase Event command, in which case I recommend turning off the Self Switch A as well or strange things are bound to happen, or turning on another switch that triggers a blank page, in which case the player will lose any chance of interacting with the event again.

Both options are possible solutions. Which one you should pick depends on how you want the event to behave when the player leaves the area and comes back later.
 

SakuraMiya

Invincible Airhead
Veteran
Joined
Jul 17, 2016
Messages
76
Reaction score
3
First Language
Spanish
Primarily Uses
From what I can see the only issue lies within horizontal collision with the player. That being the case you can do that with simple events. What you need:
  1. a parallel process event to check the virtual collision;
  2. an autorun event containing the real event commands.
Both of them can be pages of the chaser itself. The default page can be a parallel process event, while the second page can be an autorun event with a certain condition (for the sake of speaking I am going to use Self Switch A).

- - - - - - - - - - - - -​

What the parallel process is supposed to do
The parallel process event has to constantly compare the player position with the event position. If the distance is lower than or equal to a certain set distance, the Self Switch A is set to true and the autorun part starts.

You can store both your event position and your player position into variables using event commands (Control Variable) or you can use a script call. First of all decide a distance (in squares) that will determine when a collision happens (based on your image I would say two squares are enough).

To determine if the player is touching the event with a set distance of 2 it means that the difference between the player X coordinate and you event X coordinate is between -2 and 2, and the difference in their Y coordinate is within the [-1, 1] range.

To do that you need two conditional branches. If you are storing those coordinates in variables, you can simply check the variable value, if you are not, you can use the Script feature in the conditional branch command and type this
Code:
($game_map.events[your_event_id].y - $game_player.y).abs <= 1
to check y coordinates, and this
Code:
($game_map.events[your_event_id].x - $game_player.x).abs <= your_distance
to check the x coordinate.

If both of them are true, simply change the Self Switch A and set it to true. If they are not, move the event one step closer to the player.

- - - - - - - - - - - -​

What the autorun event is supposed to do
The autorun event is basically your normal event. The "Player Touch" option is emulated by the parallel process that checks the player proximity so there is no need to use it here. Simply set the page event trigger option to "Autorun" and set "Self Switch A is ON" as page condition.

The contents of this page should be the same as the contents of your normal event. Just remember that, since it is an autorun event, you have to stop it manually either by using the Erase Event command, in which case I recommend turning off the Self Switch A as well or strange things are bound to happen, or turning on another switch that triggers a blank page, in which case the player will lose any chance of interacting with the event again.

Both options are possible solutions. Which one you should pick depends on how you want the event to behave when the player leaves the area and comes back later.
Alright, I set up the variable commands and I adjusted it for the chase. But still, how do I set the collision now?
 

Attachments

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
What you need:
  1. a parallel process event to check the virtual collision;
  2. an autorun event containing the real event commands.
Both of them can be pages of the chaser itself
It looks like you did not follow my instructions.
The autorun event is basically your normal event. The "Player Touch" option is emulated by the parallel process that checks the player proximity so there is no need to use it here. Simply set the page event trigger option to "Autorun" and set "Self Switch A is ON" as page condition.
I already answered your question here, even before you were able to ask it. You did not use any conditional branches either - which are fundamental elements in collision checking - even after I explicitly said that you need them.
To determine if the player is touching the event with a set distance of 2 it means that the difference between the player X coordinate and you event X coordinate is between -2 and 2, and the difference in their Y coordinate is within the [-1, 1] range.

To do that you need two conditional branches. If you are storing those coordinates in variables, you can simply check the variable value, if you are not, you can use the Script feature in the conditional branch command and type this
From what I can see, not only does your event have more pages than needed, but it is not set in the way I explained. I recommend reading through the instructions above carefully, you will find the answer to your questions.
 

SakuraMiya

Invincible Airhead
Veteran
Joined
Jul 17, 2016
Messages
76
Reaction score
3
First Language
Spanish
Primarily Uses
It looks like you did not follow my instructions.

I already answered your question here, even before you were able to ask it. You did not use any conditional branches either - which are fundamental elements in collision checking - even after I explicitly said that you need them.


From what I can see, not only does your event have more pages than needed, but it is not set in the way I explained. I recommend reading through the instructions above carefully, you will find the answer to your questions.
Sorry about that, your explanation confused me more. I’m new at all this about conditional branches for collision, so I work better with screenshots.

(And my idea didn’t work anyway)
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
And my idea didn’t work anyway
That is something I knew by looking at your screenshots. However, I often reply from mobile so I have no access to the engine when I do, that is why I try to provide step-by-step explanation on how to do things.

Let's put it this way.

  • Step 1: create the parallel process page
Set the graphics to be the same as your normal event, the trigger should be "Parallel Process", no condition for that page (or add a condition if you need a certain switch to be on before the enemy starts chasing the player).

What to write in your contents:
Code:
@> Script:
    Fiber.yield while $game_map.events[@event_id].moving?
    dx = ($game_player.x - $game_map.events[@event_id].x).abs
    dy = ($game_player.y - $game_map.events[@event_id].y).abs
    if ((dx <= 2) && (dy <= 1))
        $game_self_switches[[$game_map.map_id, @event_id, 'A']] = true
    else
        $game_map.events[@event_id].move_toward_player
    end
That's it, your parallel process event does not need anything else.

  • Step 2: create the autorun page
When the Self Switch A is on (if you don't want to use self switch A you can change it in the code above), you trigger the second page. This page needs an autorun trigger to work as soon as the switch is turned on.

What to write in your contents:
anything you would write in the normal event.
 

SakuraMiya

Invincible Airhead
Veteran
Joined
Jul 17, 2016
Messages
76
Reaction score
3
First Language
Spanish
Primarily Uses
That is something I knew by looking at your screenshots. However, I often reply from mobile so I have no access to the engine when I do, that is why I try to provide step-by-step explanation on how to do things.

Let's put it this way.

  • Step 1: create the parallel process page
Set the graphics to be the same as your normal event, the trigger should be "Parallel Process", no condition for that page (or add a condition if you need a certain switch to be on before the enemy starts chasing the player).

What to write in your contents:
Code:
@> Script:
    Fiber.yield while $game_map.events[@event_id].moving?
    dx = ($game_player.x - $game_map.events[@event_id].x).abs
    dy = ($game_player.y - $game_map.events[@event_id].y).abs
    if ((dx <= 2) && (dy <= 1))
        $game_self_switches[[$game_map.map_id, @event_id, 'A']] = true
    else
        $game_map.events[@event_id].move_toward_player
    end
That's it, your parallel process event does not need anything else.

  • Step 2: create the autorun page
When the Self Switch A is on (if you don't want to use self switch A you can change it in the code above), you trigger the second page. This page needs an autorun trigger to work as soon as the switch is turned on.

What to write in your contents:
anything you would write in the normal event.
Alright, seems like the script works fine and all, but how I make it collision with the right point. Already tried the numbers you suggested in your first post, but it doesn’t work.

(The circle in the image shown where I want the collision point to be. The dot is the actual one)
 

Attachments

Last edited:

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
If you used the script I provided, the event should stop moving earlier. If by "collision" you mean collision in the sense of preventing player movement you simply cannot achieve that with an event. unless you move a different invisible event together with the dog itself.
 

SakuraMiya

Invincible Airhead
Veteran
Joined
Jul 17, 2016
Messages
76
Reaction score
3
First Language
Spanish
Primarily Uses
If you used the script I provided, the event should stop moving earlier. If by "collision" you mean collision in the sense of preventing player movement you simply cannot achieve that with an event. unless you move a different invisible event together with the dog itself.
Hmm….yeah, I figured it myself how to work on the collision. It all has sense now.

My only question is why if the player stops running, the chaser does it as well?
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
When that happens is the event on the parallel process page? Could you post a screenshot of the event to show how it is right now?
 

SakuraMiya

Invincible Airhead
Veteran
Joined
Jul 17, 2016
Messages
76
Reaction score
3
First Language
Spanish
Primarily Uses
When that happens is the event on the parallel process page? Could you post a screenshot of the event to show how it is right now?
The events works fine, but for some reason when the character walks instead of running, the chaser does as well.
 

Attachments

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
The event does not stop because the player stops. It stops because the event reaches its position and your second page does nothing.

I might have already said it 5 times, but I will say it once more: your second page needs an AUTORUN trigger to work. There is no player touch nor event touch involved. It must be an AUTORUN, and that is because the engine does not detect collision at that distance by default. This time I was able to test it in the engine and it works like a charm.
What the autorun event is supposed to do
The autorun event is basically your normal event.
Simply set the page event trigger option to "Autorun" and set "Self Switch A is ON" as page condition.
Step 2: create the autorun page
This page needs an autorun trigger to work

Read this
You changed the code using "(dy <= 2)" instead of "(dy <= 1)". Just so that you know it, you might think you solved the issue, but you actually caused another issue, without solving the previous one.

What happens with that is that collision is calculated when the distance on the Y axis is 2. This also means that your player can be two squares BELOW the event and it is still going to trigger.

Not only is this different from what you want to achieve, it even increases the gap between the enemy sprite, making the visual effect even worse. Changing things without knowing what you are doing is what many people call "cowboy coding". This is a wrong practice that cause a lot of harm. Not only does it create different unwanted bugs, it even makes helping you more difficult because people might no longer understand what you are trying to achieve by looking at your code.

Refrain from doing it. It is much better to give more details to the people helping you rather than going with cowboy coding.

However, if that is the only spot where you want the collision to happen, you can change the code to only check collision on that line (1 tile above your enemy sprite). If you do, the way you have to change it is not nearly similar to what you did.

Code:
if $game_map.events[@event_id].moving?
    Fiber.yield
else
    dx = ($game_player.x - $game_map.events[@event_id].x).abs
    dy = $game_map.events[@event_id].y - $game_player.y
    if ((dx <= 2) && (dy == 1))
        $game_self_switches[[$game_map.map_id, @event_id, 'A']] = true
    else
        $game_map.events[@event_id].move_toward_player
    end
end
Getting rid of the abs part gives you a signed integer as result, not an unsigned distance. Knowing this, if the event is below the player, its Y coordinate is bigger than that of the player. This means that if the result is 1, the event is 1 tile below the player. Otherwise, the result would have been -1.

Using that in the if branch, you can make sure that the event only triggers when the player is on the same line as your sprite face.

Keep in mind that if you want the collision to ONLY happen when the player is in front of the enemy, you have to change it even further. Anyway, this code only checks collisions when the event is moving horizontally. I do not know if your sprite has a different appearance when facing down. If it does, the code becomes even more complex.

Now a piece of advice for the future
Creating events is basically using a simplified version of structured programming. What does this mean? It means that even the smallest thing makes the difference, it means that you have to be careful about where you place things, how you place them and how they interact with each other. This is why, when asking for help, you should read other people posts carefully. If you get past what it looks not relevant, you might miss incredibly useful information and your event might not work as intended.

Writing posts takes time, that is an undeniable truth, no ifs and buts. If somebody decides to spend his or her time to add a certain information to his or her post, it is very unlikely that the information provided is not useful. On the contrary, the odds of that extra piece of information being necessary to let the event work properly are extremely high.

Long story short: always read other people posts carefully when receiving help. If you do not, you are simply wasting time, yours (because you are creating events that are not going to work) and theirs (because they have to answer questions that they have already answered).
 
Last edited:

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

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,045
Members
137,569
Latest member
Shtelsky
Top