- Home /
Raycast drags behind the transform that generates it
So, I have an object Raycasting something below it, but this object hits really high speeds over time (it's a racing game), as soon as I hit a velocity.magnitude of around 50, the Raycast starts lagging behind, by the time I hit the speed limit of 200, the Raycast is around 8 meters behind the transform of the object.
I tried changing the Fixed Timestep, this maybe makes the Raycast be about 4 meters behind instead of 8, but the whole games becomes slower. Everything is on FixedUpdate() as of now.
Any ideas why the Raycast updates later than my moving object? Thanks!
Answer by ReubenXXX · Jul 21, 2017 at 02:53 AM
I do not much knowledge of raycasting, but if it is lagging behind the object then just ray cast ahead of the object by adding to the position of the moving object that is ray casting Like using:transform.position + transform.forward * object.speed/ 25. There will be no lag for the 200 speed limit as ray cast will emit 8 meters ahead. 8-8 = 0 Bang on target.
Your answer
Follow this Question
Related Questions
Raycast and Physics(Ragdolls): Update() or FixedUpdate()? 1 Answer
How to make code in FixedUpdate() independent from fixed timestep? 1 Answer
Making FixedUpdate fixed-timestep-independent 3 Answers
Mouse Input for RayCast - Update or FixedUpdate 1 Answer
Multiple raycasts in same fixedupdate 3 Answers