Hi everyone,
I’m trying to implement a feature where players can open a map GUI (using a ViewportFrame that shows a 3D view of the game world) and click anywhere on the map to set a waypoint in the actual game world.
The general idea is:
- Display a scaled-down version of the map inside a
ViewportFrame. - Detect where the player clicks on the map GUI.
- Translate that click position into world coordinates.
- Set a waypoint indicator in the game world that points towards the clicked location.
I’ve tried raycasting from the ViewportFrame camera and also from the main workspace camera, but my raycasts don’t reliably detect hits on the map parts, or they return nil even when clicking on visible parts.
My questions are:
- What’s the best practice to convert clicks inside a
ViewportFrameinto real-world positions for waypoint placement? - Should I raycast against the cloned map inside the
ViewportFrameor the actual workspace map? - Are there common pitfalls with raycasting and
ViewportFramecameras I should be aware of? - Any tips for making waypoints work smoothly and accurately from a map GUI?
Any sample code, tutorials, or advice would be much appreciated!
Thanks in advance!