NPC Bus oncoming traffic detection - I need a genious
#1

Hi,
I've made a simple range detection which uses the position of the bus as a centre and checks whether anyone is in a 50 metre radius of its position - if so it stops... great.

Trouble is when you drive on the other side of the road or behind the bus it slamms on its brakes as you are in its radius... not so cool.

What i'd like to know is whether anyone could point me in the right direction of how to make the bus "look" in front of itself, almost like a beam rather than a whole road/area - i suspect this would mean all kinds of brain melting maths work but have no clue where to start!

Thanks in advance,

ozzie
Reply
#2

Well I suppose you can use:
SetPlayerVehicleVelocity( ... https://sampwiki.blast.hk/wiki/Velocity_Tutorial

and lower the speed..set a timer..lower the speed again..set a timer..lower the speed again..the finally..set the velocity to 0.
Reply
#3

You cannot do that, it only works in radius all around the point. But as (above) said, you can just make it like..

if the bus is within (radius = 50) of a player, set the velocity 50
if the bus is within (radius = 25) of a player, set the velocity 25
if the bus is within (radius = 10) of a player, set the velocity 10
if the bus is within (radius = 5) of a player, set the velocity 0 (so it stops)
Reply
#4

Hes looking for the bot to see infront of itself instead of it brakes if someone is behind it.


Go look in the npc scripts and find the "LS taxi test" script which follows the server download, this has exactly what your looking for. You just need to record your route and make it load that 1 instead (And give him a bus). The system will make it break if a player is infront of the bus (but not behind) but note that he will stop in an instant.


And about the velocity im pretty sure bots are immune to velocity as they are following a path. Im not sure but im pretty sure it's impossible to bring it away from it's path without scripting him to
Reply
#5

The LS Taxi NPC script as mentioned above by Desert, pauses the playback of the NPC when there is a player in front of it. Yes, SetPlayerVelocity and SetPlayerPos does not work on NPCs' because they are recorded.

But what you can do, is record the bus stopping at certain "bus stops". That way the players can board the bus easily.
Reply
#6

Thanks for the replies I'll look up the LS taxi test and work out how it does it

RE DJDhan - we used to record stopping at bus stops but we're going with non stop routes now so the bus will look for pedestrians and stop to see if it can help them - which when your in the middle of back o beyond after ditching your car into the river could be fairly helpful :P

Cheers again,

ozzie
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)