View unanswered posts | View active topics It is currently Sun Jan 12, 2025 6:03 am



Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
 Floating object attached to assigned actor. 
Author Message

Joined: Mon Mar 15, 2010 11:46 pm
Posts: 67
Reply with quote
Post Floating object attached to assigned actor.
See title.


An event triggers an animation loop displayed as a HUD status bar (Like the Jetpack fuel bar?)

It spawns fine and sticks above the character and all that...

... it just doesn't stick TO the character, and stays in mid air if the player moves...

So, basically, I have no idea how to do this and the search function has too much scatter and needless information about guns =.=


Wed Mar 31, 2010 10:06 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Floating object attached to assigned actor.
Find the nearest actor using SceneMan:ShortestDistance and (if it's a custom actor, check that the presetnames match) use it as the 'zero' vector to modify by your deltaY to get a point above it.


Wed Mar 31, 2010 10:11 pm
Profile

Joined: Mon Mar 15, 2010 11:46 pm
Posts: 67
Reply with quote
Post Re: Floating object attached to assigned actor.
Grif wrote:
Find the nearest actor using SceneMan:ShortestDistance and (if it's a custom actor, check that the presetnames match) use it as the 'zero' vector to modify by your deltaY to get a point above it.



No no no, I mean, I already got it to spawn on the right spot, just not to stick to it.


Should I make it an attachable instead of a particle/pixel/thingitisnow ?


Wed Mar 31, 2010 10:12 pm
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Floating object attached to assigned actor.
You can't permanently attach anything with Lua, you have to reset it's position every frame (or every 50 ms or whatever).


Wed Mar 31, 2010 10:15 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Floating object attached to assigned actor.
Just do
function Update(self)
self.Pos = Vector(actor.Pos.X, actor.Pos.Y - howevermanypixels);
end


Wed Mar 31, 2010 10:20 pm
Profile

Joined: Mon Mar 15, 2010 11:46 pm
Posts: 67
Reply with quote
Post Re: Floating object attached to assigned actor.
*Facepalms* D'ah!

T-thanks...

Edit:

Is it, like, possible to make a MOSParticle with a script that does that?
Or do I need to make it an attachable after all?


Wed Mar 31, 2010 10:28 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Floating object attached to assigned actor.
It's quite possible, though I'd need more specifics on exactly how you're doing all this to tell you just how.

Is it a custom actor, or a weapon effect, or what?


Wed Mar 31, 2010 10:55 pm
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Floating object attached to assigned actor.
That which is following the actor can be anything, if that's your question.


Wed Mar 31, 2010 11:13 pm
Profile

Joined: Mon Mar 15, 2010 11:46 pm
Posts: 67
Reply with quote
Post Re: Floating object attached to assigned actor.
INI:

Code:
AddEffect = MOSParticle
   PresetName = Stat
   Mass = 0.001
   GlobalAccScalar = 0.0
   LifeTime = 5150
   HitsMOs = 0
   GetsHitByMOs = 0
   ScriptPath = ActionHeroSoldier.rte/Devices/PartEff.lua
   SpriteFile = ContentFile
      FilePath = TesterBreachC4.rte/Devices/Timer.bmp
   FrameCount = 7
   SpriteAnimMode = 0
   SpriteAnimDuration = 725
   SpriteOffset = Vector
      X = -10
      Y = -8
   Atom = Atom
      Material = Material
         CopyOf = Air
      TrailLength = 0

LUA:
Code:
function Create(self)
local curdist = 50
for i = 1,MovableMan:GetMOIDCount()-1 do
   gun = MovableMan:GetMOFromID(i);
   if gun.ClassName == "HDFirearm" and gun.PresetName == "C-4 placer" and (gun.Pos-self.Pos).Magnitude < curdist then
      actor = MovableMan:GetMOFromID(gun.RootID);
    if MovableMan:IsActor(actor) then
      self.parent = ToActor(actor);
         local Stat = CreateMOSParticle("Stat");
            Stat.Pos = self.parent.AboveHUDPos + Vector(0,1);
            MovableMan:AddParticle(Stat);
         end
      end
   end
end



As you could probably guess the lua is attached to the fired projectile (It's a timer charge that shows how long it takes before detonation is possible by manual control) and not the gun or the actor itself.

Should I apply the :

Code:
function Update(self)
   self.Pos = Vector(actor.Pos.X, actor.Pos.Y);
end


to a new LUA file and attach that to the MOSParticle 'Stat' ?

It works, though, but it'll stop working if I stop moving.


Last edited by ajlw on Wed Mar 31, 2010 11:23 pm, edited 1 time in total.



Wed Mar 31, 2010 11:18 pm
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Floating object attached to assigned actor.
Yeah, if I'm reading you you want the Stat particle to stay with the Actor, in which case you would put that Lua attached to Stat.


Wed Mar 31, 2010 11:20 pm
Profile

Joined: Mon Mar 15, 2010 11:46 pm
Posts: 67
Reply with quote
Post Re: Floating object attached to assigned actor.
*Facedesk* I edited just as you posted.


Uhm, well, it works, sort of.

It just vanishes if I stay standing still.


Wed Mar 31, 2010 11:23 pm
Profile
User avatar

Joined: Mon Jun 29, 2009 2:40 am
Posts: 610
Location: Deep below The Map of Mars
Reply with quote
Post Re: Floating object attached to assigned actor.
ajlw wrote:
(...)to a new LUA file and attach that to the MOSParticle 'Stat' ?
No.
Stick that code in the same Lua document.
Do not attach another separate Lua document.
I hope I understood you.

Edit:
Is the particle's lifetime a factor in the disappearing?


Wed Mar 31, 2010 11:25 pm
Profile

Joined: Mon Mar 15, 2010 11:46 pm
Posts: 67
Reply with quote
Post Re: Floating object attached to assigned actor.
6 seconds, so no...


And if I do put it in the same lua document, I'm pretty sure the round fired (The bomb) will stick above my head instead... as the lua is for the round, and the particle is something different from the round and shouldn't be affiliated with the script written for the round...

... r-right?


Edit:

Tried it.

Me exploding into 50000 fleshy bits should make it obvious enough.


Wed Mar 31, 2010 11:28 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Floating object attached to assigned actor.
Okay, then this is pretty simple.

Have the lua attached to the fired shot spawn the MOSParticle.

That MOSParticle will have a script to find the nearest actor (look at the homing missile for a quick example), which it will then designate as the "target". Then, just use the update position code to keep it attached.


Wed Mar 31, 2010 11:32 pm
Profile

Joined: Mon Mar 15, 2010 11:46 pm
Posts: 67
Reply with quote
Post Re: Floating object attached to assigned actor.
I shouldn't be doing this at 0:33 AM after a party... urgh.

Kay, here goes nothing...

Edit:

Nope, too tired.
Will try tommorow, at work, or something.


Wed Mar 31, 2010 11:34 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 16 posts ]  Go to page 1, 2  Next

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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.041s | 14 Queries | GZIP : Off ]