Trigger physics update

This commit is contained in:
Antoine Pilote
2021-06-26 13:13:52 -04:00
parent c7dc3cc476
commit 8f4c5f8b08
32 changed files with 431 additions and 128 deletions

View File

@@ -18,7 +18,7 @@ class CamScript is ScriptableEntity {
_deltaTime = 0
Input.HideMouse()
//Input.HideMouse()
}
init() {}
@@ -63,7 +63,7 @@ class CamScript is ScriptableEntity {
velocity = velocity.Sqrt()
var amount = (Math.Sin(_deltaTime * (velocity * 0.01)) / 2 + 1) * _BobHeight
Engine.Log("BobAmount: %(amount)")
//Engine.Log("BobAmount: %(amount)")
var pTransform = player.GetComponent("Transform")
var pPos = pTransform.GetTranslation()

View File

@@ -26,6 +26,10 @@ class PlayerScript is ScriptableEntity {
Engine.Log("Player init")
}
update(ts) {
}
fixedUpdate(ts) {
this.CheckInput()

View File

@@ -28,7 +28,9 @@ class Scene {
return TransformComponent.new(id)
} else if (component == "Script") {
return this.GetScript_(id)
}
} else if (component == "Trigger") {
return Trigger.new(id)
}
}
@@ -63,7 +65,8 @@ class Scene {
foreign static IsCharacterControllerOnGround_(e)
//foreign static IsOnGround_(e)
foreign static TriggerGetOverlappingBodyCount_(e)
foreign static TriggerGetOverlappingBodies_(e)
}
class Entity {
@@ -78,31 +81,6 @@ class Entity {
GetComponent(component) {
return Scene.EntityGetComponent(_entityId, component)
}
// Foreign engine functions
/*
// Transform
foreign static SetTranslation_(e, x, y, z)
foreign static SetRotation_(e, x, y, z)
foreign static SetScale_(e, x, y, z)
// Character controller
foreign static SetVelocity(e, x, y, z)
foreign static SetStepHeight(e, x, y, z)
foreign static IsOnGround(e)
*/
// Light
//
/*
foreign static SetLightIsVolumetric_(e, bool)
foreign static SetLightSyncDirectionWithSky_(e, bool)
foreign static SetLightColor_(e, r, g, b)
// Camera
foreign static SetCameraFov_(e, fov)
foreign static SetCameraType(e, type)
foreign static SetCameraDirection_(e, x, y, z)
*/
}
class TransformComponent {
@@ -181,3 +159,23 @@ class Camera {
}
}
class Trigger {
construct new(id) {
_entityId = id
}
GetOverlappingBodyCount() {
return Scene.TriggerGetOverlappingBodyCount_(_entityId)
}
GetOverlappingBodies() {
bodies = Scene.TriggerGetOverlappingBodies_(_entityId)
entities = []
for(b in bodies) {
entities.add(Entity.new(b))
}
return entities
}
}

View File

@@ -0,0 +1,29 @@
import "Scripts/ScriptableEntity" for ScriptableEntity
import "Scripts/Engine" for Engine
import "Scripts/Scene" for Scene, Trigger
import "Scripts/Math" for Vector3
import "Scripts/Input" for Input
import "Scripts/Physics" for Physics, CollisionResult
class TriggerScript is ScriptableEntity {
construct new() {
}
init() {
Engine.Log("Hello, I'm a trigger")
}
update(ts) {
}
fixedUpdate(ts) {
var trigger = this.GetComponent("Trigger")
Engine.Log("Current overlap: %(trigger.GetOverlappingBodyCount())")
}
exit() {
}
}