psst
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 83f98f1f40209b141a597a83c862a61f
|
||||
guid: f9337852f7cf29848b42f674d396732d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
|
||||
@@ -1,21 +1,95 @@
|
||||
local dir = true
|
||||
local minY = -300
|
||||
local maxY = -25
|
||||
-- ============================================================================
|
||||
-- PSXSplash Example Script
|
||||
-- Demonstrates all working Lua events and API calls.
|
||||
-- Attach this to a PSXObjectExporter via the "Lua File" field.
|
||||
-- ============================================================================
|
||||
|
||||
function doSomething(first, other)
|
||||
local pos = first.position
|
||||
-- Per-object state (each object gets its own copy of these locals)
|
||||
local bobAmplitude = 50 -- vertical bob range
|
||||
local bobSpeed = 2 -- bob increment per frame
|
||||
local bobPhase = 0
|
||||
|
||||
if dir then
|
||||
pos.y = pos.y + 10
|
||||
if pos.y >= maxY then
|
||||
dir = false
|
||||
end
|
||||
else
|
||||
pos.y = pos.y - 10
|
||||
if pos.y <= minY then
|
||||
dir = true
|
||||
end
|
||||
-- ============================================================================
|
||||
-- LIFECYCLE EVENTS
|
||||
-- ============================================================================
|
||||
|
||||
--- Called once when the object is first loaded into the scene.
|
||||
function onCreate(self)
|
||||
Debug.Log("Object created!")
|
||||
local pos = Entity.GetPosition(self)
|
||||
Debug.Log(" start pos: " .. pos.x .. ", " .. pos.y .. ", " .. pos.z)
|
||||
end
|
||||
|
||||
--- Called every frame while the object is active.
|
||||
--- WARNING: This runs on a 33 MHz MIPS R3000 — keep it light!
|
||||
function onUpdate(self)
|
||||
-- Simple vertical bob
|
||||
bobPhase = bobPhase + bobSpeed
|
||||
if bobPhase > 360 then bobPhase = bobPhase - 360 end
|
||||
|
||||
local pos = Entity.GetPosition(self)
|
||||
pos.y = pos.y + PSXMath.Sign(180 - bobPhase) * bobAmplitude / 60
|
||||
Entity.SetPosition(self, pos)
|
||||
end
|
||||
|
||||
--- Called when the object is destroyed or the scene unloads.
|
||||
function onDestroy(self)
|
||||
Debug.Log("Object destroyed!")
|
||||
end
|
||||
|
||||
-- onEnable / onDisable are available but omitted here to reduce log noise.
|
||||
-- function onEnable(self) Debug.Log("Object enabled") end
|
||||
-- function onDisable(self) Debug.Log("Object disabled") end
|
||||
|
||||
-- ============================================================================
|
||||
-- INTERACTION EVENTS (requires PSXInteractable component)
|
||||
-- ============================================================================
|
||||
|
||||
--- Called when the player interacts with this object.
|
||||
function onInteract(self)
|
||||
Debug.Log("Player interacted!")
|
||||
local active = Entity.IsActive(self)
|
||||
Entity.SetActive(self, not active)
|
||||
end
|
||||
|
||||
-- ============================================================================
|
||||
-- COLLISION / TRIGGER EVENTS
|
||||
-- ============================================================================
|
||||
|
||||
--- Called when this object's collider overlaps another.
|
||||
function onCollision(self, other)
|
||||
Debug.Log("Collision with another object")
|
||||
end
|
||||
|
||||
--- Called on the first frame two triggers overlap.
|
||||
function onTriggerEnter(self, other)
|
||||
Debug.Log("Trigger enter")
|
||||
end
|
||||
|
||||
--- Called every frame while two triggers continue to overlap.
|
||||
function onTriggerStay(self, other)
|
||||
-- Expensive! Avoid heavy work here.
|
||||
end
|
||||
|
||||
--- Called when two triggers stop overlapping.
|
||||
function onTriggerExit(self, other)
|
||||
Debug.Log("Trigger exit")
|
||||
end
|
||||
|
||||
-- ============================================================================
|
||||
-- INPUT EVENTS
|
||||
-- ============================================================================
|
||||
|
||||
--- Called when any button is pressed this frame.
|
||||
function onButtonPress(self, button)
|
||||
if button == Input.CROSS then
|
||||
Debug.Log("Cross pressed!")
|
||||
end
|
||||
end
|
||||
|
||||
first.position = pos
|
||||
--- Called when any button is released this frame.
|
||||
function onButtonRelease(self, button)
|
||||
if button == Input.CROSS then
|
||||
Debug.Log("Cross released!")
|
||||
end
|
||||
end
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2080a81a20451b74bb4fed47cde1eb64
|
||||
guid: c993fd0fc3a7b2e4db45e291e983ac47
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
@@ -7,4 +7,4 @@ ScriptedImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: d364a1392e3bccd77aca824ac471f89c, type: 3}
|
||||
script: {fileID: 11500000, guid: 74e983e6cf3376944af7b469023d6e4d, type: 3}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 98c8fecb427143042be70f00ac1ebb42
|
||||
guid: e5eb77d7823c1c944ba10953ae01f796
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
|
||||
@@ -134,4 +134,4 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 9
|
||||
version: 10
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef90866ae3c8e3241995606c20a6f335
|
||||
guid: 6bf1caff36887d44fa357159c84fe954
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a2d025695ecb074a811681d20c569b0
|
||||
guid: 2ca98fa730fe5fa4ea239123eb09887b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbf5265ad7d363446800065929646d36
|
||||
guid: 5688ba03f531c3245a838793c0ae7f93
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
|
||||
Reference in New Issue
Block a user