Get the pointed entity at a further distance (making a gun)

Post Reply
LC Creations
Member
Posts: 159
Joined: Mon Feb 18, 2019 02:53
GitHub: LandonAConway

Get the pointed entity at a further distance (making a gun)

by LC Creations » Post

So, I want to make a gun. The objective is to point the gun at another object like up to 50 nodes away and punch it with the specified tool capabilities. I have created a method to get a pos at a specified distance in the look direction of the player but this isn't good enough. Even if someone pointed out a existing mod that does this, that would help.
cdb_ac3a146dcafb

User avatar
sirrobzeroone
Member
Posts: 593
Joined: Mon Jul 16, 2018 07:56
GitHub: sirrobzeroone
Contact:

Re: Get the pointed entity at a further distance (making a gun)

by sirrobzeroone » Post

I'm not very good at using it myself but I know raycast is the way to go - check out runs bow mod:

viewtopic.php?t=24512&p=370856

LC Creations
Member
Posts: 159
Joined: Mon Feb 18, 2019 02:53
GitHub: LandonAConway

Re: Get the pointed entity at a further distance (making a gun)

by LC Creations » Post

sirrobzeroone wrote:
Sat Jun 20, 2020 08:02
I'm not very good at using it myself but I know raycast is the way to go - check out runs bow mod:

viewtopic.php?t=24512&p=370856
I heard raycast does NOT pick up any entities. The only option would be to actually pick up the entity or player object.
cdb_ac3a146dcafb

User avatar
Zughy
Member
Posts: 301
Joined: Thu Mar 26, 2020 18:23
GitHub: belongs_to_microsoft
In-game: Zughy
Location: Italy
Contact:

Re: Get the pointed entity at a further distance (making a gun)

by Zughy » Post

Didn't test it but it should work. Let's say you have a raycast called your_raycast

Code: Select all

local pointed_thing = your_raycast.next() 
if pointed_thing and pointed_thing.type == "object" and pointed_thing.ref and not pointed_thing.ref:is_player() then
	local pointedEntity = hit.ref
end

User avatar
sirrobzeroone
Member
Posts: 593
Joined: Mon Jul 16, 2018 07:56
GitHub: sirrobzeroone
Contact:

Re: Get the pointed entity at a further distance (making a gun)

by sirrobzeroone » Post

Pretty sure the entity bug thing was a pre the full release of 5. Im fairly sure it was fixed as below 6241 says merged:

https://github.com/minetest/minetest/pull/6241

https://github.com/minetest/minetest/issues/6157

User avatar
runs
Member
Posts: 3225
Joined: Sat Oct 27, 2018 08:32

Re: Get the pointed entity at a further distance (making a gun)

by runs » Post

Crafter the game get the pointed thing all the time. Check it.

Anyway, a engine method to expose it would be cool.

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests