Jump to content

Follow() not following


YouGroove
 Share

Recommended Posts

I made a custom AI script for soldier and i called Follow() in start , even put it in physic loop.

Soldier has character physics with mass , it is enabled, it has player as target in script and navmesh is build for the level

 

self.entity:Follow(self.target.entity,self.speed,self.maxaccel)

 

Any idea ?

 

follow.jpg

Stop toying and make games

Link to comment
Share on other sites

Ok i should read the Command reference some times laugh.png

Returns true if a path can be plotted to the target entity, otherwise false is returned.

But "follow" name command is misleading for me, a name like canReach() ro reachable() would make more sense.

Stop toying and make games

Link to comment
Share on other sites

No. Follow does indeed lets a character follow another entity. So the name is correct. That it returns if a route could be calculated or not is just an addition so you can check if following is even possible.

 

So that it does not work must have another reason.

 

My first guess is that self.target.entity is not really your entity.

 

When you have Script.target=nil--entity "Target" in your script self.target is already your entity.

So the correct call would be

self.entity:Follow(self.target,self.speed,self.maxaccel)

 

If that does not help you can post your code and maybe we can find your problem?

Link to comment
Share on other sites

I made it work with GotoPoint and it worked, then chaging code with Follow worked after that.

if(dist < self.maxDist and dist > self.minDist and self.mode ~="chase") then
 self.mode="chase"	
	 self:updateState("chase")
 self.entity:Follow(self.target,self.speed,self.maxaccel)
end

 

I just find Follow command very unstable even playing with acceleration values, the character some times turns suddenly very fast, or it is some moment like some freezz, also sometimes it continues on trajectory too much and follow the player too late.But it's perhaps better optimized ?

Stop toying and make games

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...