Right now there's no easy way to find out what part of a node the player is looking at, using the Lua API.
(That is, the exact position where the camera vector first intersects with a node/entity selection box)
It's relatively simple to figure out when you're dealing with full nodes, but complex nodeboxes make it a lot harder. I have a (mostly) working solution, but it's very complicated and there are a few situations where it won't work. (I have no way of compensating for the view bobbing animation, for example) (Plus, if any new node box types are added to the game (like the "disconnected" nodeboxes being added in version 0.5), I'll have to update my code.)
If there was a built in function which tells you exactly where the player is looking, that would be very helpful.
pos, face = player:get_pointed_pos() (or something)
(The ability to tell which face of the node you are pointing at is also very important)
There are a ton of situations where this would be useful.
Getting the exact spot the player is pointing at
-
- Member
- Posts: 818
- Joined: Tue Apr 14, 2015 01:59
- GitHub: raymoo
- IRC: Hijiri
- In-game: Raymoo + Clownpiece
Re: Getting the exact spot the player is pointing at
What about Raycast? (which is coming in the 5.0.0 modding API)
Every time a mod API is left undocumented, a koala dies.
- 12Me21
- Member
- Posts: 873
- Joined: Tue Mar 05, 2013 00:36
- GitHub: 12Me21
- Location: (Ignore all of my posts before 2018)
Re: Getting the exact spot the player is pointing at
Yeah, that does exactly what I neededByakuren wrote:What about Raycast? (which is coming in the 5.0.0 modding API)
I was going to update my post but I forgot...
- Wuzzy
- Member
- Posts: 4786
- Joined: Mon Sep 24, 2012 15:01
- GitHub: Wuzzy2
- IRC: Wuzzy
- In-game: Wuzzy
- Contact:
Re: Getting the exact spot the player is pointing at
No need to wait:
Code: Select all
* `minetest.pointed_thing_to_face_pos(placer, pointed_thing)`: returns a position
* returns the exact position on the surface of a pointed node
- 12Me21
- Member
- Posts: 873
- Joined: Tue Mar 05, 2013 00:36
- GitHub: 12Me21
- Location: (Ignore all of my posts before 2018)
Re: Getting the exact spot the player is pointing at
That doesn't work with nodes that use nodeboxes.Wuzzy wrote:No need to wait:Code: Select all
* `minetest.pointed_thing_to_face_pos(placer, pointed_thing)`: returns a position * returns the exact position on the surface of a pointed node
- Hybrid Dog
- Member
- Posts: 2828
- Joined: Thu Nov 01, 2012 12:46
- GitHub: HybridDog
Re: Getting the exact spot the player is pointing at
You'd just need to test the position on all selection boxes and select the one nearest to the player.
Who is online
Users browsing this forum: No registered users and 3 guests