Roadster vehicle dynamics

Could the culprit for your performance caused by your custom terrain? The default terrain uses Bullet’s btHeightfieldTerrainShape, and I don’t remember the performance being bad.

Yes, the terrain is custom and uses btHeightfieldTerrainShape but also I use AI to prevent collisions, which uses raycasts too, and it seems somehow it chokes on large amount of raycasts per frame. After I implemented priority queue of raycasts and removed physics from distant vehicles (I run simple car physics on them which is fully custom - just simple integration of 3 values) I can run about 20 vehicles at 20 fps.

@slapin Please stay on the topic. If you have an issue, please create another thread of your own.

@weitjong, he is on topic.

@slapin - right, the raycast performance issue. Have you tried using the RaycastSingleSegmented() fn for ray lengths > 10 meters? You’ll get a better performance than the RaycastSingle() fn.

@Lumak, If you say so. Have fun.

Ah, thanks for RaycastSingleSegmented() - this is really makes difference. I can run ~30 vehicles this way. I think using threaded raycast would make it even better, but I don’t have guts to look that direction. Thanks a lot! This looks like I can increase. performance for NPCs too.

RaycastSingleSegmented() is based on Bullet’s raycasting.
Might be relevant:

Bullet’s author confirms here raycasts are thread safe when not stepping the world.

Network testing - what you see in the video is on the client side. The host is sitting at the starting line. All other drivers are AI.

1 Like

Nice !
I am also playing with it lately , creating scenes with race cars.
I uploaded some video , all of them are AI driven , runs also flawlessly on low range Android and iOS mobiles


Oh, sweet! Wow, you got a full level designed and created already, awesome. That’s probably my most difficult part in my game development. I get to that point in my prototypes and … just draw blank.

What type of AI pathing do you use?

For AI ,
I am using “Chase The Rabbit” algorithm .
Basically each car is following its own virtual invisible “rabbit” .
Each rabbit (node) is following predefined markers that form different paths , with some random salt modified each frame causing it to jump from path to path
Every frame :
The acceleration of the car is modified based upon its distance to its “rabbit”
The steering of the car is modified based of direction of the car in relation to its “rabbit” in world space
In addition I am raycasting several rays from each car to the sides and front to detect collision with other cars , and modify steering & acceleration accordingly .

Regarding the level itself , I am using my “wild imagination” :slight_smile:
Basically adding & removing some stuff and see how it looks , a lot of trial and error , still not happy with it.


Tid bit of info about my vehicle setup for network:

  • rigibody - REPLICATED
  • collisonshape - REPLICATED
  • prefab xml car node layout: hubs, steering wheel node, driver node, static models - all LOCAL
  • raycast vehicle (btRaycastVehicle) - LOCAL
  • wheels - LOCAL
  • sounds - LOCAL
  • skid track - LOCAL

My 1st semi-completed level testing.


I’ve just looked at my profiler view of the level and the race from the vid above and got my total memory usage is shown as 7.2MB. I added extra dump in the largest memory user for each type of resource and got:

rscgrp: Texture2D, largest: name=Textures/vp_sky_v3_007_1024LGT.png, size=2.7 M 
rscgrp: Technique, largest: name=Techniques/NoTexture.xml, size=1.4 k           
rscgrp: XMLFile, largest: name=track6/track6.xml, size=47.3 k                   
rscgrp: Image, largest: name=Textures/UI.png, size=128.0 k                      
rscgrp: Font, largest: name=Fonts/Anonymous Pro.ttf, size=12.2 M                
rscgrp: Model, largest: name=Models/Sphere.mdl, size=41.9 k                     
rscgrp: Material, largest: name=Materials/pineMat.xml, size=588 b               
rscgrp: TextureCube, largest: name=Textures/Level0Cube.xml, size=128.3 k        
rscgrp: Sound, largest: name=Sounds/engine-prototype.ogg, size=119.9 k          
rscgrp: Shader, largest: name=Shaders/GLSL/LitSolid.glsl, size=122.9 k          
rscgrp: Animation, largest: name=Racers/Racer_Idle.ani, size=79.2 k             

My question is, how is the total memory 7.2MB while the font usage is 12.2MB?