This means that if the drone reaches its destination offscreen, this unchanged velocity will cause it to keep moving.
Maybe you could keep track of what velocity should be when asleep, and set it in OnEntityWake, even 0 (if it had any velocity prior to sleep) so that it stops moving (might need to also set its position to whatever the stop coordinates are supposed to be?).
Unsure if you'd want to wait a frame after entity wake (which at that point would require position correcting if there was any velocity).
Dunno, just throwing some suggestions. I'm sure you'll figure it out in a clean consistent manner.
Here's the relevant bits.
local function OnDeliveryProgress(inst, t, len, origin, dest) local dx = dest.x - origin.x local dz = dest.z - origin.z local k = _calc_k(t, len, dx, dz) local k1 = math.min(1, _calc_k(t + FRAMES, len, dx, dz)) local x, y, z = inst.Transform:GetWorldPosition() x = origin.x + k * dx z = origin.z + k * dz inst.Transform:SetPosition(x, y, z) if not inst:IsAsleep() then local vx, vy, vz = inst.Physics:GetMotorVel() if k1 > k then --assert(FRAMES == 1 / 30) local speed = (k1 - k) * math.sqrt(dx * dx + dz * dz) * 30 inst.Physics:SetMotorVel(speed, vy, 0) else inst.Physics:SetMotorVel(0, vy, 0) end end
local function OnStopDelivery(inst, dest) inst._x, inst._z = nil, nil if not inst:IsAsleep() then local _, vy, _ = inst.Physics:GetMotorVel() inst.Physics:SetMotorVel(0, vy, 0) end
local function OnEntityWake(inst) if not inst.SoundEmitter:PlayingSound("idle") then inst.SoundEmitter:PlaySound("rifts5/wagdrone_flying/idle", "idle") end end local function OnEntitySleep(inst) inst.SoundEmitter:KillSound("idle") end
Oh and lastly:
local isscanning = inst.scanning:value() if IsFlyingPermittedFromPoint(x, y, z) then if not isscanning then SetScanning(inst, true) inst:Show() if not inst.SoundEmitter:PlayingSound("idle") then inst.SoundEmitter:PlaySound("rifts5/wagdrone_flying/idle", "idle") end end
This bit here doesn't check if the entity isn't asleep, erroneously allowing the sound to start playing during entity sleep.
- Order a Scout Drone to explore some area, make sure that while it's moving, you're away enough for it to unload.
- Wait for it to stop fully.
- Move/teleport to it again.
- Notice how it'll keep moving until unloaded again despite being supposed to be still in place.
For the idle sound issue, have the drone go into the "vault" area while unloaded, then have it exit the area.
A developer has marked this issue as fixed. This means that the issue has been addressed in the current development build and will likely be in the next update.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now