Jump to content

Scout drone can keep moving if it was offscreen when it reached its destination and stopped


hoxi
  • Pending

This happens because its physics velocity is only updated while the entity is awake (which is fine):

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

But it's not updated on entity wake to match what it should have (at least for when supposedly having stopped moving):

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

Maybe you could keep track of what velocity should be when asleep, and set it in on entity wake, even 0 (if it had any physics velocity prior to sleep).

Unsure if you'd want to wait a frame after entity wake. Might need to also set its position to whatever the stop coordinates are supposed to be?

 

 

Slightly related:

    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.

Also.. does the drone really need to just disappear when flying over areas where it's not allowed to do so and to scan..? Feels a little weird to have it pop in and out of existence when traversing such areas..

Since scanning gets disabled, it might be enough to just let it disable the scanning visuals? If not, maybe have some sort of fade-in or VFX when it disappears and appears?

 

And lastly, the drone currently doesn't reveal areas while the player is still connecting, but maybe it shouldn't move at all if the player hasn't received world info yet?

        if owner and owner.player_classified then
            if owner._PostActivateHandshakeState_Server ~= POSTACTIVATEHANDSHAKE.READY then
                return -- Wait until the player client is ready and has received the world size info.
            end
            if math2d.DistSq(x, z, inst._x, inst._z) >= 16 then
                inst._x, inst._z = x, z
                owner.player_classified.MapExplorer:RevealArea(x, 0, z)
				inst.components.maprevealer:RestartPrivateRevealCooldown()
            end
        end

You could maybe make it so drones spawned through wx78_dronescouttracker don't immediately try to move, and listen for the "ms_skilltreeinitialized" event on the player inst (which is fired on setting the post activate handshake state to READY), and then allow them to move.


Steps to Reproduce
  • Order a Scout Drone to explore some area, make sure that while it's moving, you move away enough for it go into entity sleep range.
  • Wait for it to stop fully.
  • Move/teleport to it again.
  • Notice how it'll keep moving until it goes into entity sleep range 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.




User Feedback


There are no comments to display.



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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
  • Create New...