|
it hurts my brain to think of a way to do this. im not asking for a script, i just need ideas as to how to approach this.
player is nearby an object(region3 or .magnitude, and do i have to use a loop for it?), billboard gui appears on top of said object (client only, no FE, i plan to use a billboard gui in startergui and set its adornee), and when the player is actually nearby, hit E to do stuff to the object (user input service)
the problem is that i cant find a better way to check for the object other than using an infinite loop, or as said in another thread, runservice (both on client). and if i wanted to be able to interact with multiple objects (NOT all at once), how can i find a good way to identify such object?
any ideas? |
|
|
|
I did the exact same thing lol.
I tried to make an NPC with dialog using a magnitude detector and a sketchy button system. |
|
xformulaJoin Date: 2016-04-03 Post Count: 69 |
Maybe u should not even use the magnitude or region3 approach. instead use something like Mouse.Target and if they are hovering their mouse over a part which u want to interact with will display a gui with an e and if they press e then they can interact with it
|
|
|
it sounds like a viable idea until u realize that it'd be less efficient to hover over the object and hit e rather than just clicking on it
i'm not trashing your idea but still, there has to be a better way of doing this than that and the initial approach |
|
xformulaJoin Date: 2016-04-03 Post Count: 69 |
i think the most efficient method would be doing it with runservice. are u trying to find a more efficient method because of lag?
|
|
xformulaJoin Date: 2016-04-03 Post Count: 69 |
wait instead of using magnitude or region3 u can set the MaxDistance of the billboard gui
|
|
|
yes i am actually, since ive heard stories of unbearable lag due to while true do loops and such. also with runservice, i get the idea but how would i check for objects in workspace?
workspace.brick --if i do this then i'd have to do it for every single thing i want to interact with |
|
|
as for max distance, i would do that if it werent for the fact that i cant locate objects to set the adornee of the billboard gui to. again, directly referencing a specific object would lead to painstaking amounts of typing |
|
xformulaJoin Date: 2016-04-03 Post Count: 69 |
just use a infinite while loop and just use waits between calulations that will reduce your lag
|
|
FangousJoin Date: 2010-07-03 Post Count: 4448 |
I'm doing something like this right now actually
Currently I'm using a RenderStepped loop checking for magnitude. Since it's the only loop on the client, it's not laggy at all. Then I use worldtoscreenpoint for the GUI. Looks better than billboard guis (imo). |
|
xformulaJoin Date: 2016-04-03 Post Count: 69 |
probably the best option of detecting would be a region 3 since u dont have to use as many calculations
|
|
|
the question still stands
how would i locate the objects? |
|
|
if i use region3, would i just have to draw it around the player?
also doesn't region3 just stay in the same place, not constantly being updated? |
|
xformulaJoin Date: 2016-04-03 Post Count: 69 |
yeah it stays in the same place.
u can use renderstepped to update it and have it around your character
you can use workspace's FindPartsInRegion3WithIgnoreList to get parts that are in your region3
|
|
xformulaJoin Date: 2016-04-03 Post Count: 69 |
idk if it would be effient tbh since u would be looping a loop at that point just use the other guys idea of using a magnitude with renderstepped
|
|
|
nwe problem; i cant set the region3's cframe or size. anyone know any tricks to getting around this? |
|
|
|
|
so after learning that i cant move region3's, i switched to magnitude and so far ive gotten good results. the only problem now is that i cant seem to find a solid way to identify the object (given that its inside of a model, which is inside of a folder).
what if i want to identify the object but there are multiple copies of it? |
|
|
|
|
How I would do it is I'd check if the object is near the player (use magnitude). If they are close, check the magnitude between the object and the Mouse.Hit.p. If the mouse is close to it, show the billboard.
Just use an infinite loop, they ain't that bad. As long as you don't over use it, you'll be fine.
|
|
|
isn't .magnitude for 3d objects and mouse.hit.p for 2d objects? |
|
|
magnitude is used to find the distance (in studs) between two vectors.
ex:
(Vector3.new(0,0,0) - Vector3.new(0,5,0)).Magnitude --would equal 5
Mouse.Hit.p is a vector3 value (its 3d basically) and it returns the position the mouse is in based off of worlds space.
|
|