|
| 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 |
|
|
|
| 05 Apr 2017 11:18 PM |
| click detector or mouse.Target |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 05 Apr 2017 11:49 PM |
| I know but "when player is looking at something?" |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 05 Apr 2017 11:52 PM |
| yeah but that's still different |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 06 Apr 2017 12:04 AM |
| Lol you 2 are always fightin |
|
|
| Report Abuse |
|
|