Nextbot, the proper way?

Hello, I’ve been working on a “nextbot” game for quite some time now, despite the premise of the game being entirely different to others, most of the main things are prevalent, like running from nextbots. Now, the way im doing my pathfinding is using simplepath and a constant loop that is entirely based on magnitude checks. If you want to take a look, you can here: SussyTest - Roblox ( ignore the sloppy menu, its a placeholder, the map is also taken from an uncopylocked place and is temporary, every script is made by me though ), inside the main game upon pressing a button the nextbots will toggle and follow you around. You will notice that they will not move too smooth and once you are downed they have no idea what to do and stand there awkwardly, furthermore annoying me is that if i stand in an unreachable spot, they will stand there again and do nothing, what i want to achieve is more or so what evade or nico’s nextbots have where they will still try to follow you despite your path being invalid to compute and handle the teleporting passively. Now, am I doing this wrong, if not how could i achieve what i said there? Any help is appreciated.

1 Like

Making NPCs/Agents behave in a way you want to can be a bit difficult. The more control you want to give to themselves, the more expensive it could be to have that NPC/Agent.

For smooth movement, my guess is that the their main loop (I assume it updates their targets every time it loops) is running slow.
If the bots all share the same loop, then the bots could only update their target as fast as the loop can iterate.
If each bot has their own loop, then it could be the target logic itself is slowing down the loop. (I am unsure of how expensive a magnitude style search would be)

The pathfinding system itself could also be the slow part, but I have used SimplePath in the past and have not have many problems with it.

One thing that might help speed is connecting target updates to RunService.Heartbeat, as this would update at the speed the server can handle (which is about 60 normally.)

As for bots standing around, this would be something you may have to solve with some ingenuity!
Here is an example: If a bot cannot find a target, then it would use a function to generate some random position that is away from the last known position of a target.

Hope this helps.

1 Like

The loop is not the problem, the pathfinding is working properly but by smooth i mean visualisement, their strafe accel for instance which gives the illusion of smooth movement making it less robotic. Each nextbot has a different loop of themselves along with methods and variables, as their “ai” is object oriented

1 Like

Oh, and to answer to your last comment regarding the random position, each player will leave a position behind every 10 seconds or so and sometimes the bots are told to go to a random position from the ones left behind

1 Like

Ah, I see.

I don’t have a lot of experience with NPCs/agents/bots, but if I had to guess a way to smooth out their movement (if you are using humanoids) would be to increase/decrease their movement speed.
The longer a bot is moving in a straight line, the faster it gets.
Other then that, I am not really sure.

1 Like

This is what im currently doing to achieve the effect:

function nextbot:_EnableAcceleration()
		local bf = Instance.new("BodyForce", self._primary)
		table.insert(self._bin, bf)
		self._botModel.Humanoid:GetPropertyChangedSignal("WalkToPoint"):Connect(function()

			if self._primary.Velocity.Magnitude > 50 then
				bf.Force = (self._botModel.Humanoid.WalkToPoint - self._primary.Position).Unit * 200
			else
			bf.Force = (self._botModel.Humanoid.WalkToPoint - self._primary.Position).Unit * 0
			end
		if self._botModel.Humanoid.WalkToPoint == nil then
				bf.Force = Vector3.new(0, 0, 0)
			end
	
	end)
end

it is functioning as intended but, just not smooth enough, the bots are still looking robotic at times

1 Like

Hmm. This is outside of what I have ideas of. The only thing I could think of is decreasing how fast the bodyforce can increase in a given time.

Other then that, I would just be throwing darts blindfolded.

Thanks for trying to help though!

1 Like