Should I use RayCast or something else?

For my RPG project, I’m trying to figure out if RayCast is something I should use. If anyone remembers Super Mario RPG for SNES, my game mechanics for my proof of concept are to be able to run around a simple town, interact with NPCs and then venture out and run into enemies.

I plan on using a controller or keyboard for input, but I don’t really have a need for a mouse (I’m trying to stay to 90s RPG roots). That being said, should I use a RayCast for determining layers for Interacting with or is there a simpler way to go about it? My pseudocode idea basically reads, when near NPC and facing towards it, press button to interact. With enemies, the pseudocode is when collision with enemy occurs, go to battle scene, etc.

Anyone with a bit more experience on RayCasting that can weight in on this?

I think a raycast could work in this case.

An alternative I could think of could be to use a trigger collider that is constantly floating in front of the player character to check what to interact with.

Maybe a combination of both; a collider around the player character may be better for detecting when to go into the battle scene and a raycast to detect what to interact with may be the way to go.

1 Like

Hey Matt,

Thanks for the feedback. In re-reviewing the raycaster lesson, I came to the conclusion that I should have a raycaster. Originally, I kind of felt like I wanted to keep the mouse out of the inputs. Though in all reality, having the mouse and click-to-move as an available option to players may be beneficial. With the raycaster implemented, I can set up for clicking on enemies, even though they will transition to a battle scene. I think this can help make setting up menus and interacting with NPCs a lot faster too.

1 Like

Privacy & Terms