Get the pointed entity at a further distance (making a gun)
-
- Member
- Posts: 159
- Joined: Mon Feb 18, 2019 02:53
- GitHub: LandonAConway
Get the pointed entity at a further distance (making a gun)
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
- 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)
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
viewtopic.php?t=24512&p=370856
-
- Member
- Posts: 159
- Joined: Mon Feb 18, 2019 02:53
- GitHub: LandonAConway
Re: Get the pointed entity at a further distance (making a gun)
I heard raycast does NOT pick up any entities. The only option would be to actually pick up the entity or player object.sirrobzeroone wrote: ↑Sat Jun 20, 2020 08:02I'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
cdb_ac3a146dcafb
- 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)
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
- 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)
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
https://github.com/minetest/minetest/pull/6241
https://github.com/minetest/minetest/issues/6157
Re: Get the pointed entity at a further distance (making a gun)
Crafter the game get the pointed thing all the time. Check it.
Anyway, a engine method to expose it would be cool.
Anyway, a engine method to expose it would be cool.
Who is online
Users browsing this forum: No registered users and 7 guests