in0finite / SanAndreasUnity

Open source reimplementation of GTA San Andreas game engine in Unity
https://discord.gg/p6jjud5
MIT License
2.13k stars 352 forks source link

Dynamics objects #89

Closed CrosRoad95 closed 4 years ago

CrosRoad95 commented 4 years ago

Adds some models on grove street and near by los santos can be destroyed by walking, shooting or running over them, they respawns after 30 second. I didn't add all objects which originaly are dynamic.

I don't created synchronization between all players, i don't want synchronize rubbish right now. Even desync exists right now, boxes doesn't affect gameplay, they only decoration.

Sometimes object at spawn disappearing, i don't know how to fix it.

image

in0finite commented 4 years ago

This is the logic you should use for dynamic objects:

DynamicObject class should inherit MapObject. When it gets in range of player (OnShow() is called), you spawn new game object with rigid body and all other components. Attach OutOfRangeDestroyer to these spawned game objects, so that they are destroyed when too far away.