Fire raycast when the player is near the object

There are no stupid questions, just stupid answers.
5 posts Page 1 of 1
Bishop
Posts: 88
Joined: Wed Dec 09, 2015 2:30 am
by Bishop » Sat Nov 16, 2019 9:57 pm
Hi,guys...I need advice ....when a player is near an interactive object...I need automatically display text about this object.....or just do something with the object.
marauder2k9
Posts: 320
Joined: Wed Feb 18, 2015 7:36 am
by marauder2k9 » Mon Nov 18, 2019 2:18 pm
you could fire a raycast where the player is pointing the crosshair, or create a small trigger that displays the info on screen near the object it depends on how hidden or obvious you want the object to be
Duion
Posts: 1434
Joined: Sun Feb 08, 2015 1:51 am
 
by Duion » Mon Nov 18, 2019 10:36 pm
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.
Bishop
Posts: 88
Joined: Wed Dec 09, 2015 2:30 am
by Bishop » Wed Nov 20, 2019 7:54 pm
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.
Duion
Posts: 1434
Joined: Sun Feb 08, 2015 1:51 am
 
by Duion » Wed Nov 20, 2019 8:46 pm
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.
5 posts Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests