blade2xs

Villager
Member
Joined
Feb 7, 2021
Messages
19
Reaction score
3
First Language
English
Primarily Uses
RMMZ
I didn't find a flexible enough line of sight / vision plugin for RMMV so I'm working on a system for a game that has Character version accessible via script for RMMZ since there doesn't really appear to be visions scripts that can be affected by lighting, obstacles, stealth behavior etc. I may also augment with sound detection as well since they can use similar concepts.

Some of the ideas I had were to hide / show character vision so you could for example equip a ring that lets you see your enemy's line of site, if it is dark and you walk outside of the radius of a light, if you are sneaking around etc.

Here is the first pass at it, I'll try to do daily updates:
 

Attachments

  • vision_sample_01.gif
    vision_sample_01.gif
    724.4 KB · Views: 18
Last edited:

blade2xs

Villager
Member
Joined
Feb 7, 2021
Messages
19
Reaction score
3
First Language
English
Primarily Uses
RMMZ
Ok I got vision following the direction the characters are facing. Next is the actual collision detection of "seeing" the character
 

Attachments

  • vision_sample_02.gif
    vision_sample_02.gif
    460.8 KB · Views: 5

blade2xs

Villager
Member
Joined
Feb 7, 2021
Messages
19
Reaction score
3
First Language
English
Primarily Uses
RMMZ
Here is an update,
I figured out how to bind a collision rectangle shaped sprite on the main player, just not sure it the right area to do so...

SceneManager.onSceneStart

Is the even I check if the player has the visionCollision object attached and if it does not, i create a new instance to attach. It is not an expensive task to re-attach if it gets lost but I wasn't sure if this was the right event to do this in. seems ok though.

This part was easy to set up and I completed it on Friday. You can see it in the sample with the red box around the player, which is resizeable, I just kept it 48x48 for now until I get the collision detection working.

Which leads me to the challenge I've been trying to figure out... I am actually rotating the sprites for the vision because there are cases where I was smooth turning and it can easily be done via sprite rotation. the problem is the collision detection for a rotated rectangle (and polygon) is super complex for my rusty Highschool/college geometry and trig brain so I am research different techniquest on how to determine a collision / point intersect and it deals with sin and cosin functions, which I have not had to do for like 20 years.

I was hoping to use an RMMZ collision detection behavior but it doesnt seem possible the way it is built. I am open to ideas and thoughts from others though
 

Attachments

  • vision_sample_03.gif
    vision_sample_03.gif
    532.6 KB · Views: 8

blade2xs

Villager
Member
Joined
Feb 7, 2021
Messages
19
Reaction score
3
First Language
English
Primarily Uses
RMMZ
Update. I have it partially working... Just struggling with getting the hit detection vertices to actually match with the sprite I draw (see the yellow vision lines and red character detection box)

I added this js library to RMMZ https://github.com/davidfig/pixi-intersects to help withj collision detection. there are a few bugs in his lib like always centering on a sprite and not taking the location from the pivot point (I am using rotating sprites)

so I am still working on this just trying to figure out the Maths and this guy's library (rotation makes it much harder to do hit detection
 

Attachments

  • vision_sample_04.gif
    vision_sample_04.gif
    487 KB · Views: 5

Latest Threads

Latest Posts

Latest Profile Posts

I wrote RPGMakerMZ JavaScript reference in Japanese.
But I think you'll be able to read it through the translator.

back in April of 2019, I watched my friend's art stream on twitch. that was when I got inspired to draw most of the assets for my game. it's been a LONG journey since, but totally worth it.
RPG MZ multiplayer in development
Square-Enix, why you didn't released the classic Dragon Quests on Steam yet? :kaocry:
This is by far my most favorite boss monster I've made, its name is Gosck

Forum statistics

Threads
109,139
Messages
1,042,481
Members
141,647
Latest member
Juckz
Top