-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from dojoengine/sub-dojo.c
chore: include dojo.c submodule in bindings
- Loading branch information
Showing
48 changed files
with
23,595 additions
and
23,956 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "c2cs"] | ||
path = c2cs | ||
url = https://github.com/Larkooo/c2cs | ||
[submodule "Bindings/dojo.c"] | ||
path = Bindings/dojo.c | ||
url = https://github.com/dojoengine/dojo.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using Dojo; | ||
using UnityEngine; | ||
|
||
public class CameraFollow : MonoBehaviour | ||
{ | ||
public WorldManager worldManager; | ||
public float height = 10.0f; // height of the camera above the center point | ||
public float damping = 1.0f; // damping factor to smooth camera movement | ||
public float speed = 10.0f; // speed of camera movement | ||
|
||
|
||
void Update() | ||
{ | ||
if (worldManager.Entities().Length > 0) | ||
{ | ||
Vector3 centerPoint = GetCenterPoint(); | ||
Vector3 offset = new Vector3(0, height, -height); | ||
Vector3 desiredPosition = centerPoint + offset; | ||
Vector3 smoothedPosition = Vector3.Lerp(transform.position, desiredPosition, damping * Time.deltaTime); | ||
transform.position = smoothedPosition; | ||
|
||
transform.LookAt(centerPoint); | ||
} | ||
|
||
// Camera control | ||
float moveHorizontal = Input.GetAxis("Horizontal"); | ||
float moveVertical = Input.GetAxis("Vertical"); | ||
|
||
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical); | ||
transform.Translate(movement * speed * Time.deltaTime, Space.World); | ||
} | ||
|
||
Vector3 GetCenterPoint() | ||
{ | ||
if (worldManager.Entities().Length == 1) | ||
{ | ||
return worldManager.Entities()[0].transform.position; | ||
} | ||
|
||
var bounds = new Bounds(worldManager.Entities()[0].transform.position, Vector3.zero); | ||
for (int i = 0; i < worldManager.Entities().Length; i++) | ||
{ | ||
bounds.Encapsulate(worldManager.Entities()[i].transform.position); | ||
} | ||
return bounds.center; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.