Author |
Message |
numgun
Joined: Sat Jan 13, 2007 11:04 pm Posts: 2932
|
Changing an Actor's body sprite depending on condition?
I'm making a multimode vehicle, and if what the topic title says its possible, it will make the vehicle look much more dynamic.
So let me rephrase the question:
Is is possible to change an Actor, AHuman, ACrab or an ACraft's main sprite with Lua ingame on the run? Say let it check for a condition or a switch and then assign the sprite the function is supposed to give it.
An an example, a variable spider tank: When in position A, it would switch to sprite A (spider mode). And relatively when in position B, it would switch to sprite B (tank treads mode).
|
Sun Jun 28, 2009 7:29 pm |
|
|
TheLastBanana
DRL Developer
Joined: Wed Dec 13, 2006 5:27 am Posts: 3138 Location: A little south and a lot west of Moscow
|
Re: Changing an Actor's body sprite depending on condition?
|
Sun Jun 28, 2009 7:35 pm |
|
|
Areku
Joined: Fri Oct 17, 2008 9:46 pm Posts: 5212 Location: The Grills Locker.
|
Re: Changing an Actor's body sprite depending on condition?
A spider robot that transforms into a tank with threads? You've definitely been playing too much Lost Planet, Numgun. But wouldn't it be better to make the legs rotate until under the main body ( you may remember that the spider robot in LP had the treads attached to the outer part of the legs ) using a crouchpath or something, and then making the unit move using a jeep-like script? That way, the leg movement would look more dynamic, and you could define the movement speed on each of the modes more easily. ( I guess )
|
Sun Jun 28, 2009 8:08 pm |
|
|
numgun
Joined: Sat Jan 13, 2007 11:04 pm Posts: 2932
|
Re: Changing an Actor's body sprite depending on condition?
Areku wrote: You've definitely been playing too much Lost Planet, Numgun. Hahaha stop it! xD You busted me again although that was really just an example, but yes, the idea is certainly from that NEVEC tank in Lost Planet. I'm really making the Turbokat from Swat Kats. (Its a VTOL jet fighter) It will need this to change between flight modes: (VTOL mode <-> Jet mode)
|
Sun Jun 28, 2009 8:26 pm |
|
|
piipu
Joined: Mon Jun 30, 2008 9:13 pm Posts: 499 Location: Finland
|
Re: Changing an Actor's body sprite depending on condition?
If you want to use Mail's attachable lua, you could have a few attachables on top of the chest and do Scale = 0 to all but one of them. This way it could have animations.
|
Sun Jun 28, 2009 9:07 pm |
|
|
numgun
Joined: Sat Jan 13, 2007 11:04 pm Posts: 2932
|
Re: Changing an Actor's body sprite depending on condition?
piipu wrote: If you want to use Mail's attachable lua, you could have a few attachables on top of the chest and do Scale = 0 to all but one of them. This way it could have animations. : / No thanks. Thats just making the simple matter way too complicated. The function TLB pointed out is pretty much exatcly what I could use. And not only that, but it can do alot more than I though.
|
Sun Jun 28, 2009 11:17 pm |
|
|
Geti
Joined: Sun Jul 13, 2008 9:57 am Posts: 4886 Location: some compy
|
Re: Changing an Actor's body sprite depending on condition?
self.Frame works fine. just animate it with lua timers. something like Code: [create stuff] self.issquirtingfluideverywhere = false self.frametimer = Timer() self.framedelay = number self.framenumber = 0 self.frameamount = self.FrameCount / 2
[updatestuff] if self.frametimer:IsPastSimMS(self.framedelay) then self.frametimer:Reset() if self.issquirtingfluideverywhere then self.Frame = self.frameamount + self.framenumber else self.Frame = self.framenumber end end self.framenumber = self.framenumber + 1 if self.framenumber > self.frameamount then self.framenumber = 0 end end or whatever.
|
Sun Jun 28, 2009 11:28 pm |
|
|
Asatruer
Joined: Thu May 28, 2009 3:59 pm Posts: 209
|
Re: Changing an Actor's body sprite depending on condition?
A spider-tank that can walk or roll brought to my mind images of Shirow's Fuchikoma/Tachikoma/Think-Tank from the various Ghost in the Shell comics/movies/tv-shows. That video has a number of annoying graphics effects added, but it was the most complete look at the movement abilities. Could the same Frame lua work on the legs of an ACrab, or AHuman? Or is it limited to the main sprite?
|
Mon Jun 29, 2009 6:58 pm |
|
|
numgun
Joined: Sat Jan 13, 2007 11:04 pm Posts: 2932
|
Re: Changing an Actor's body sprite depending on condition?
I wonder if this Frame() will work on guns. Then 'd be able to make dymanic energy guns that will open up to show its deadliness when it has been charged enough.
|
Mon Jun 29, 2009 7:37 pm |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
Re: Changing an Actor's body sprite depending on condition?
Frame() would be a function.
gun.Frame is a property; it indicates the frame number.
If you iterate through all attachables and then make sure that your gun is attached to the right actor, then you should be able to animate through the frames, yes (object oriented programming yano).
|
Mon Jun 29, 2009 7:40 pm |
|
|
Geti
Joined: Sun Jul 13, 2008 9:57 am Posts: 4886 Location: some compy
|
Re: Changing an Actor's body sprite depending on condition?
yes it could. it can also be used to animate pinned objects. it would only work on dedicated actors though, unless you wanted to do a heap of iteration..
|
Tue Jun 30, 2009 12:50 am |
|
|
CrazyMLC
Joined: Fri Dec 22, 2006 4:20 am Posts: 4772 Location: Good news everyone!
|
Re: Changing an Actor's body sprite depending on condition?
Could you, say, make a dropship more damaged when it's health went below 30?
|
Tue Jun 30, 2009 12:54 am |
|
|
Geti
Joined: Sun Jul 13, 2008 9:57 am Posts: 4886 Location: some compy
|
Re: Changing an Actor's body sprite depending on condition?
yes. if you can check a variable on something, you can change something in response to it. just try ♥♥♥♥ out, its not that hard.
|
Tue Jun 30, 2009 1:03 am |
|
|
numgun
Joined: Sat Jan 13, 2007 11:04 pm Posts: 2932
|
Re: Changing an Actor's body sprite depending on condition?
CrazyMLC wrote: Could you, say, make a dropship more damaged when it's health went below 30? Absolutely. With the sound of things it might be as easy as this: Code: if self.Health < 30 then --Sprite changing function is a GO end
|
Tue Jun 30, 2009 1:08 am |
|
|
CrazyMLC
Joined: Fri Dec 22, 2006 4:20 am Posts: 4772 Location: Good news everyone!
|
Re: Changing an Actor's body sprite depending on condition?
Fun stuff. Maybe that could be used in build 24/25.
|
Tue Jun 30, 2009 1:10 am |
|
|
|