Getting the exact spot the player is pointing at

User avatar
12Me21
Member
 
Posts: 873
Joined: Tue Mar 05, 2013 00:36
Location: (Ignore all of my posts before 2018)
GitHub: 12Me21

Getting the exact spot the player is pointing at

by 12Me21 » Sun Sep 02, 2018 20:58

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.
 

Byakuren
Member
 
Posts: 816
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

by Byakuren » Wed Sep 05, 2018 22:28

What about Raycast? (which is coming in the 5.0.0 modding API)
Every time a mod API is left undocumented, a koala dies.
 

User avatar
12Me21
Member
 
Posts: 873
Joined: Tue Mar 05, 2013 00:36
Location: (Ignore all of my posts before 2018)
GitHub: 12Me21

Re: Getting the exact spot the player is pointing at

by 12Me21 » Thu Sep 06, 2018 01:20

Byakuren wrote:What about Raycast? (which is coming in the 5.0.0 modding API)

Yeah, that does exactly what I needed
I was going to update my post but I forgot...
 

User avatar
Wuzzy
Member
 
Posts: 3624
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: Getting the exact spot the player is pointing at

by Wuzzy » Wed Sep 19, 2018 07:22

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
My creations. I gladly accept bitcoins: 17fsUywHxeMHKG41UFfu34F1rAxZcrVoqH
 

User avatar
12Me21
Member
 
Posts: 873
Joined: Tue Mar 05, 2013 00:36
Location: (Ignore all of my posts before 2018)
GitHub: 12Me21

Re: Getting the exact spot the player is pointing at

by 12Me21 » Mon Sep 24, 2018 20:16

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

That doesn't work with nodes that use nodeboxes.
 

User avatar
Hybrid Dog
Member
 
Posts: 2719
Joined: Thu Nov 01, 2012 12:46

Re: Getting the exact spot the player is pointing at

by Hybrid Dog » Thu Oct 04, 2018 10:26

You'd just need to test the position on all selection boxes and select the one nearest to the player.

‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪
 


Return to Feature Discussion



Who is online

Users browsing this forum: Bing [Bot] and 2 guests