generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: when player is looking at something?

Previous Thread :: Next Thread 
PandaDemic is not online. PandaDemic
Joined: 21 Jan 2011
Total Posts: 13422
05 Apr 2017 10:57 PM
what would i use to determine this?
in my case im making a door and i though it'd be cooler if i made the door a 'press e to open'
but realized right away i had no idea how to go about making it

i dont think raycasting would be optimal but i mean it would work...


are you not ENTERTAINED!??!
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
05 Apr 2017 11:18 PM
click detector or mouse.Target
Report Abuse
PandaDemic is not online. PandaDemic
Joined: 21 Jan 2011
Total Posts: 13422
05 Apr 2017 11:34 PM
figured it out with trial and error, your method did infact work for me!
thanks wunder!


are you not ENTERTAINED!??!
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
05 Apr 2017 11:39 PM
What's so bad about raycasting?

Using mouse.Target/ClickDetector will only be valid if the mouse is over it, not if they're looking at it.

What you could do is see if they're looking the direction of it via projecting the offset onto the lookVector and checking if it's greater than some value.

i.e.
local off = (cameraPos - partPos).unit
local dot = off:Dot(cameralookVec)
if dot >= 0.8 then -- looking in the 'general direction' (about 37 degrees)
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
05 Apr 2017 11:40 PM
ye but this makes it so that your mouse has to be over the door rather than you have to face the center of it
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
05 Apr 2017 11:41 PM
and if you get close to the door facing sideways it will not detect that the door is within view
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
05 Apr 2017 11:44 PM
"ye but this makes it so that your mouse has to be over the door rather than you have to face the center of it"
I know that's what yours does, I literally just said that:
"will only be valid if the mouse is over it"
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
05 Apr 2017 11:46 PM
i understand but it would make more sense if you could open a door just by mousing over it rather than having to face the center
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
05 Apr 2017 11:49 PM
I know but "when player is looking at something?"
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
05 Apr 2017 11:51 PM
"though it'd be cooler if i made the door a 'press e to open'"
hed have to be looking at it to have his mouse on it
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
05 Apr 2017 11:52 PM
yeah but that's still different
Report Abuse
PandaDemic is not online. PandaDemic
Joined: 21 Jan 2011
Total Posts: 13422
05 Apr 2017 11:56 PM
decided on a 1st person gameplay, so mouse contact is the only contact needed
thanks again though!


are you not ENTERTAINED!??!
Report Abuse
szkiller_dev is not online. szkiller_dev
Joined: 07 Oct 2016
Total Posts: 3572
06 Apr 2017 12:04 AM
Lol you 2 are always fightin
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image