View unanswered posts | View active topics It is currently Tue Mar 19, 2024 5:06 am



Reply to topic  [ 1 post ] 
 problem with smoke-spawning bullet lua (solved via workaroun 
Author Message

Joined: Mon Dec 21, 2015 9:30 am
Posts: 89
Reply with quote
Post problem with smoke-spawning bullet lua (solved via workaroun
Code:
function Create(self)

   local Effect
   local Offset = self.Vel*(20*TimerMan.DeltaTimeSecs)   -- the effect will be created the next frame so move it one frame backwards towards the barrel
   
   for i = 1, 2 do
      Effect = CreateMOSParticle("Tiny Smoke Ball 1", "Base.rte")
      if Effect then
         Effect.Pos = self.Pos - Offset
         Effect.Vel = (self.Vel + Vector(RangeRand(-20,20), RangeRand(-20,20))) / 30
         MovableMan:AddParticle(Effect)
      end
   end
   
   if PosRand() < 0.5 then
      Effect = CreateMOSParticle("Side Thruster Blast Ball 1", "Base.rte")
      if Effect then
         Effect.Pos = self.Pos - Offset
         Effect.Vel = self.Vel / 10
         MovableMan:AddParticle(Effect)
      end
   end
end


this code works fine until you come too close to an entity that deletes (absorbs, gets hit by) the bullet before it has travelled a frame's worth. this then spawns the smoke way behind.

when it comes to walls and other terrain being shot, it spawns the smoke at its current position if you are too close to the wall (shooting into it). that is, too far forward.

one fix would be to somehow detect the origin weapon and use its muzzle position. is it possible to do that with a reliable method, i.e. not closest-weapon or anything like that?

another would be to somehow run the code on the very creation. is that possible or will it always be one frame too late?

EDIT: solved by just spawning smoke from the weapon's code. took a while to convert everything but it works.


Fri Apr 06, 2018 12:59 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.164s | 15 Queries | GZIP : Off ]