I am using Roblox’s free model called ‘Van’, and inside the ‘Scripts’ folder we see Chassis
we can require it, and do stuff like Chassis.InitializeDrivingValues() and stuff
and now we see Chassis.UpdateSteering() | this function steers the vehicle (-1 is left and 1 is right)
now all I want to do is somehow steer pointing precisely at a position (or a part)
i tried stuff like (car.Position - part.Position).Unit:Dot(part.CFrame.LookVector) I do not know if I did anything wrong or so but it does not really work (it steers right if the part is on the right and the same on the left, but it’s not accurate at all) (and i don’t want to use parts)
so its Chassis.UpdateSteering(VALUE, Chassis.GetAverageVelocity())
again, I need to steer facing a position (or a part) correctly
Is it continuously updating the steering angle, or is it just inputting the full left or full right inputs (1 or -1) into the steering section of the script and telling the steering to go ‘full left’ or ‘full right’?
If you can continuously update the angle between the vehicle and the target position you may be able to reduce the vehicle’s steering angle (not make it full left or the full right steering angles) needed to reach the target.
it does not continuously update the steering unless you loop it, and all I need is the thing you said (i am not good at these) you can choose any value from -1 to 1 (0.84 or -0.43 and more)
You need it to continuously update while steering, otherwise it’ll sense that the target is off to the left, turn full left, but not know when it’s pointing at the target or going past the angle to the target.
What is the actual steering command in the script? By this I don’t mean the input (-1 or 1) but what causes the Van to turn? That is where you need to focus.
Try posting that section of the script so we can see what is being done. We can’t troubleshoot without it. Remember to post it here with 3 backticks (```) before and after the block of script so it stays properly formatted.
Roblox has a model called ‘Van’ and everything is in ‘chassis’
we can require the chassis (which is a module)
now we can do Chassis.UpdateSteering(VALUE, Chassis.GetAverageVelocity()) and don’t worry about GetAverageVelocity() but worry about the VALUE which can be ANY number between -1 and 1
Now, I need to get the exact value that when done, the wheels are ‘looking’ at a position
^^^ I would use the Dot product but I don’t think it’s the choice
I’m just asking for the method to get the exact value that will steer making the wheels look at a 3D position in space
UpdateSteering will steer. The first argument is the amount of steering (0 to 1 is right, -1 to 0 is left, 0 is front) and the second argument is the average velocity of the van (doesn’t really matter).
To apply speed we can do Chassis.UpdateThrottle(Chassis.GetAverageVelocity(), (-1 to 1))
As I said, try looking into Roblox’s van model, and please help me out
I am developing a massive open-world game and I’m making the AI for both the cars and humanoids, but it doesn’t matter for now
Please tell me if you need more information and explain what you really need in greater detail so I can give the same amount of detail you need
This is without looking at the Van code or anything but for the first value you must supply some sort of ratio between the van ‘LookVector’ and the position of the target. Given the AverageVelocity. Speed=Distance/Time sort of thing. Calculate the distance that will be covered by the van from it’s velocity (over a time of your choice). Then use the difference between the vans ‘LookVector’ and the target to find the ratio -i.e. power-, and direction, of steering required.
i dont need the distance and all of that since its already done in the module (I think)
all I need are some examples of code and I can choose the best and from that ill rework
this is the UpdateSteering’s code (the variables and all of that are clear)
function Chassis.UpdateSteering(steer, currentVel)
local baseSteer = steer
local targetSteer = 0
local vehicleSeat = Chassis.GetDriverSeat()
local maxSpeed = VehicleParameters.MaxSpeed
local maxSteer = VehicleParameters.MaxSteer
local currentVelocity = vehicleSeat.Velocity
if LimitSteerAtHighVel then
local c = SteerLimit * (math.abs(currentVel)/VehicleParameters.MaxSpeed) + 1
--decrease steer value as speed increases to prevent tipping (handbrake cancels this)
steer = steer/c
end
SteeringPrismatic.TargetPosition = steer * steer * steer * maxSteer
end -- SteeringPrismatic is a PrismaticConstraint