Repeating Boulder Spawn + Collision on Player

Hello, 


I am completely stuck here... need some help.. 2 days tweaking it with no answer..


So I want to make an boulder spawn on certain point and at the end of the road it will teleport back just like a continuous rolling boulder on the cliff.


At the other hand, if the event(boulder) hit the player, the player will blinking and lose some HP.


This is my attempt:

Spoiler
1485283156296.jpg


1485283059292.jpg

As the result, the boulder is not teleported back to the top, even if I have set conditional variable X and Y. And also the damage collision not working correctly. (I am using Galv Event Start Types). If anyone know how to make this work, please help.


Thank you
Use autonomous movement for the boulder movement and keep the content on event touch - that way when the boulder moves on the player, you can have it trigger the HP and a change back to start position with two or three simple commands in the content.


Then have an independent event on parallel process only checking if the boulder is at the end of the line (by checking and comparing coordinates) and transfer it to the start when it is. That checking parallel can do that for every boulder on the map if you have more than one.


But do not use the set move route command inside a parallel event that way - that always creates lag and timing problems, because it was never intended to be used that way.


Just use autonomous movement (the option you still have on fixed position), that is what it is intended to be used for.
To illustrate Andar's example:

Spoiler
Boulder, with collision detection:


EDIT: Better yet, use the following scriptlet in the conditional: 



event = $gameMap.event(this._eventId); event.isCollidedWithPlayerCharacters(event.x, event.y)


event_01.png


Parallel event to reset boulder (note that the .event(2) here will need to be changed to the event ID of your boulder):


event_02.png
@Andar @DuncanS Hello there, thank you for the replies, really help me a lot. Now I managed to make the boulder rolling and collide trigger when touching the player.


The only thing that bugged me now is that the autonomous movement of the boulder will not continuously moving over and over again


when the player is not at the screen.


Let's say that I got a 40y map size, if I stand and wait on coordinate 38y, the boulder will not coming down again.


I need to move to coordinate 14y to make the boulder roll again(boulder moving only IF the character is on the same screen as the event)


Is this normal? Any ways to trick around it?


Thank you
It's an optimization so Game_Character instances don't move around offscreen on large maps, which could cause lag.


Since it's based on a check for how near the object is to the screen, it can be disabled on a per-event basis. Put this script at the top of the events you want to continue moving offscreen:


event = $gameMap.event(this._eventId);
/*
* Hacky - make sure this event is always
* considered 'near the screen'
*/
event.isNearTheScreen = function() {
return true;
}


Like it says though, this is a bit of a hacky solution.
@DuncanS Sweet! Now it is perfect just like what I intended to do. Still curious if there is other solution without touching the script.


You know, exploring many ways. xD


Thank you again!

Spoiler
1485325589750.gif
@DuncanS @gundriveth


The first screenshot of DuncanS example is wrong and not an illustration of what I meant.


Change the trigger to event touch and remove the conditional branch with the script line completely - the event content should only be the three commands change HP, flash screen and transfer player.


Let the engine handle the collission by event touch, there is absolutely no need for a parallel on the boulder - that only creates lag.


And there is also a better solution to the problem of off-screen movement, one that was given several times in the last few weeks but I don't have the link, you'll have to search for it.


Done the way above, all events will always move - that will create a lot of lag.


The better way is to include a check for a notetag and return true only if the event checked does have the notetag for always move. Then you include that notetag on the boulder event, but not on the other events that don't have to move - a lot less lag.
Let the engine handle the collission by event touch



Ah, that makes more sense. Still a bit rusty on eventing, thanks:

Spoiler
event_03.png



Note that this way, you'll need to move the snippet for off-screen movement to the parallel event:

Spoiler
event_04.png



As this could get bulky with multiple events that need to move off-screen, you could throw the snippets into a one-off event that erases itself.

Done the way above, all events will always move - that will create a lot of lag.


The better way is to include a check for a notetag and return true only if the event checked does have the notetag for always move. Then you include that notetag on the boulder event, but not on the other events that don't have to move - a lot less lag.



There's maybe a cleaner way to do this repeatably with a plugin, but the snippet I gave will only change the function on the specified event object, not all events.
Right on, I am using the one with Event Touch on the boulder and another event Parallel to check.


After searching with keywords "off-screen movement", there were so many answers, not sure if that is what you mention on the solution.


For now, I will stick to the solution we got here.


Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/repeating-boulder-spawn-collision-on-player.74078/