Author |
Message |
Asklar
Data Realms Elite
Joined: Fri Jan 07, 2011 8:01 am Posts: 6211 Location: In your office, earning your salary.
|
Gibbing self after slowing down into a set speed
I want to gib an object if it's speed gets reduced a lot, how could I do it? Until now my code looks like this: Code: function Update(self)
if self.Vel < (5,5) or self.Vel < (-5,-5) or self.Vel < (5,-5) or self.Vel < (-5,5) then self:GibThis(); end end But it's not working.
|
Fri Mar 04, 2011 9:34 pm |
|
|
Roast Veg
Data Realms Elite
Joined: Tue May 25, 2010 8:27 pm Posts: 4521 Location: Constant motion
|
Re: Gibbing self after slowing down into a set speed
Code: function Update(self) if self.Vel.Magnitude <= 25 or self.Vel.Magnitude >= -25 then self:GibThis() end end
|
Fri Mar 04, 2011 9:36 pm |
|
|
Asklar
Data Realms Elite
Joined: Fri Jan 07, 2011 8:01 am Posts: 6211 Location: In your office, earning your salary.
|
Re: Gibbing self after slowing down into a set speed
Thanks, that worked perfectly.
Edit: Wait a second, not so perfectly. The lua console give me this error: Attempt to call method "GibThis" (a nil value)
What's wrong then?
|
Fri Mar 04, 2011 9:41 pm |
|
|
Roast Veg
Data Realms Elite
Joined: Tue May 25, 2010 8:27 pm Posts: 4521 Location: Constant motion
|
Re: Gibbing self after slowing down into a set speed
Try putting a semicolon (;) after gibthis.
|
Fri Mar 04, 2011 9:47 pm |
|
|
Asklar
Data Realms Elite
Joined: Fri Jan 07, 2011 8:01 am Posts: 6211 Location: In your office, earning your salary.
|
Re: Gibbing self after slowing down into a set speed
Still, same error.
|
Fri Mar 04, 2011 9:47 pm |
|
|
Roast Veg
Data Realms Elite
Joined: Tue May 25, 2010 8:27 pm Posts: 4521 Location: Constant motion
|
Re: Gibbing self after slowing down into a set speed
Is the thing actually being destroyed? If so then it could be that it's calling an update or two before actually disappearing. If not then try: Code: function Update(self) if self.Vel.Magnitude <= 25 and self.ToDelete ~= true then self:GibThis() end end] EDIT: DERP ME, try this instead. Thank you CaveCricket48.
|
Fri Mar 04, 2011 9:52 pm |
|
|
Asklar
Data Realms Elite
Joined: Fri Jan 07, 2011 8:01 am Posts: 6211 Location: In your office, earning your salary.
|
Re: Gibbing self after slowing down into a set speed
I keep getting the same error.
I placed a function on it when it is destroyed, so I can recognize that the particle is actually gibbing, but after it's lifetime rather than after reducing its speed.
|
Fri Mar 04, 2011 9:57 pm |
|
|
Roast Veg
Data Realms Elite
Joined: Tue May 25, 2010 8:27 pm Posts: 4521 Location: Constant motion
|
Re: Gibbing self after slowing down into a set speed
What is your object? It sounds like it cannot gib anyway. Set: Code: self.ToDelete = true; instead.
|
Fri Mar 04, 2011 10:07 pm |
|
|
Asklar
Data Realms Elite
Joined: Fri Jan 07, 2011 8:01 am Posts: 6211 Location: In your office, earning your salary.
|
Re: Gibbing self after slowing down into a set speed
A mo pixel. Now I realized I'm an idiot =D MOPixels don't gib Thanks. A lot.
|
Fri Mar 04, 2011 10:13 pm |
|
|
Roast Veg
Data Realms Elite
Joined: Tue May 25, 2010 8:27 pm Posts: 4521 Location: Constant motion
|
Re: Gibbing self after slowing down into a set speed
You can make it look like they gibbed by creating object in the destroy function.
|
Fri Mar 04, 2011 10:31 pm |
|
|
Asklar
Data Realms Elite
Joined: Fri Jan 07, 2011 8:01 am Posts: 6211 Location: In your office, earning your salary.
|
Re: Gibbing self after slowing down into a set speed
Yep, that was what I did.
You see, I've seen some explosive round codes, and they all looked fairly the same to me.
So I decided to create my own because of 2 reasons: 1) Learning, progresing, tried to make something "different" in my own way. 2) I didn't want to ask anyone for his code.
|
Fri Mar 04, 2011 10:35 pm |
|
|
|