Jump to content

Something wrong when Inheriting boat velocity in complexprojectile component


Littlefat1213
  • Pending

Actually this issue has existed since long time before, and i'd share you my terrible moment at first of all :

SOLUTION:

function ComplexProjectile:Launch(targetPos, attacker, owningweapon)
	......

    self:CalculateTrajectory(pos, targetPos, self.horizontalSpeed)

	-- if the attacker is standing on a moving platform, then inherit it's velocity too
	local attacker_platform = attacker ~= nil and attacker:GetCurrentPlatform() or nil
	if attacker_platform ~= nil then
		local vx, vy, vz = attacker_platform.Physics:GetVelocity()
      ---------------------- HERE'S THE FIX ----------------------
      vx, vz = VecUtil_RotateDir(vx, vz, self.inst.Transform:GetRotation() * DEGREES)
      ------------------------------------------------------------
	   self.velocity.x = self.velocity.x + vx
	   self.velocity.z = self.velocity.z + vz
	end

    if self.onlaunchfn ~= nil then
        self.onlaunchfn(self.inst, attacker, targetPos)
    end

    self.inst:AddTag("activeprojectile")
    self.inst:StartUpdatingComponent(self)
end

-----------------------------------------------------------------------------------------------------------------------------

by the way, i'll appreciate a lot if another issue of boat can be fixed:

 

the boat has been prevented multiple collisions with the same object in very short time periods , it works and no leak spawn when the boat reach the shore after the first collision with shore(TheWorld's ID existed in boat_physics._recent_collisions). while reloading the game will make the collision happens since the recent collision table is cleared.

Spoiler

And Physics:GetVeloctiy seems got wrong result in certain timestamp, it got the motorvel value instead vel value when OnUpdate called, just a guess: it init as motorvel and need some time to calculate the vel.

 


Steps to Reproduce

As Above




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...