Jump to content

Fire raycast when the player is near the object


Bishop

Recommended Posts

A trigger zone is probably the better and easier solution instead of constantly having to check for objects, it also allows you finer control on what you define as "close enough" to interact, the trigger then can also be used for interaction or another trigger.


Personally I'm not that much of a fan of guiding the player through automatic events, if designed well a game can work without such things, in the past games usually did not have help texts, GUIs, triggers or hints to tell you where, how and with what you can interact, you would have to figure it out by yourself.


I would design first without those things and then have players test it and see how well it works or if help is needed through texts or whatever.

Link to comment
Share on other sites

Thanks...trigger solution sounds great...I have raycasting implemented but

...when mouse click ( mouse button1) but I need fire ray just right cursor (cross) pointing over the item without mouse clicks events.

All interactive items would be in the "GameItem" internal name....that are similar to the groups in the Godot engine.

....so if object Is in group/have internal name "GameItem" ray Is shooting from eye point to the declared vector and range (from 0 to 4.0 range)...is this possible?

like in the Godot engine:

var ray_collider = cam_ray.get_collider()

if cam_ray.is_colliding() and ray_collider.is_in_group("item"):

info.text = str(ray_collider.name)

else:

info.text = str("")

"cam_ray" is a RayCast node in the Godot engine somethink like pre-made datablock with changeable properties in the Torque engine...I think.

Link to comment
Share on other sites

One thing I use that sounds similar to what you want is a containerRayCast it checks if you are near something, not just a raycast from your mouse, but all around.


My bots use that to check if an enemy is near, but they run on a tick rate, where they perform an action every tick which is like every second or so. So if you really want to do that you would have to shoot your raycasts constantly in intervals of x seconds.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...