Jump to content

Recommended Posts

Heya. I have a character who is a deer. Ideally, other deer will kind of gravitate towards them when they're near. I slapped the "saltlick" tag on them and it works pretty well for this purpose, but it also attracts beefalo, koalefants, and volt goats.

Does anyone know a way I can accomplish this without the extra mobs?

Edited by Birdskull
Link to comment
https://forums.kleientertainment.com/forums/topic/109285-solved-attracting-deer/
Share on other sites

Maybe you can do this so only if deers are near you then you get the tag

 

Spoiler

--above masterpostinit
local function LookForDeer(inst)
	if inst.components.health:IsDead() or inst:HasTag("playerghost") then return end -- Don't if dead
	local x, y, z = inst.Transform:GetWorldPosition()
	local deer = TheSim:FindEntities(x, y, z, 10,{"deer"})
	
	if #deer > 0 then
		inst:AddTag("saltlick")
	else
		inst:RemoveTag("saltlick")
	end
end

--inside masterpostinit
inst:DoPeriodicTask(1, LookForDeer)

 

 

40 minutes ago, Warbucks said:

Maybe you can do this so only if deers are near you then you get the tag

 

  Hide contents


--above masterpostinit
local function LookForDeer(inst)
	if inst.components.health:IsDead() or inst:HasTag("playerghost") then return end -- Don't if dead
	local x, y, z = inst.Transform:GetWorldPosition()
	local deer = TheSim:FindEntities(x, y, z, 10,{"deer"})
	
	if #deer > 0 then
		inst:AddTag("saltlick")
	else
		inst:RemoveTag("saltlick")
	end
end

--inside masterpostinit
inst:DoPeriodicTask(1, LookForDeer)

 

 

omg, that is a 100x easier than what I was trying to do. Works great! Thanks so much.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...