|
Post by Speedrun Labs on Jul 24, 2014 19:24:03 GMT
Hello, the new update introduces a bug for game objects with a Rigidbody2D.
The code is in Killable.cs:
void OnDespawned() { this.spawnerSet = false;
// reset velocity if (this.body.useGravity && !this.body.isKinematic) { this.body.velocity = Vector3.zero; this.body.angularVelocity = Vector3.zero; }
// add code here to fire when despawned Despawned(); }
The error is:
MissingComponentException: There is no 'Rigidbody' attached
Thanks, Joe
|
|
DarkTonic Dev
Administrator
Posts: 4,229
Posts: 4,229
Member is Online
|
Post by DarkTonic Dev on Jul 25, 2014 5:10:55 GMT
If there is no Rigidbody, does your combat actually work? I can add a check for null rigidbody, but first I want to make sure it works without a rigidbody. Or are you using a 2d rigidbody?
|
|
|
Post by Speedrun Labs on Jul 25, 2014 5:45:44 GMT
Rigidbody2D only. I commented the reset velocity stuff, so I'm ok but just letting you know, for other users that are doing 2D games
|
|
DarkTonic Dev
Administrator
Posts: 4,229
Posts: 4,229
Member is Online
|
Post by DarkTonic Dev on Jul 25, 2014 6:46:05 GMT
Ok cool, please clarify: do the combat features still work like that? I can change the code to check for 2d rigidbody.
|
|
|
Post by Speedrun Labs on Jul 25, 2014 7:06:06 GMT
Ya, so far I see no changes if I comment out both sections that say "// reset velocity" because all my rigidbodies are 2D and those sections set normal (3D) rigidbodies' velocity to zero. Actually..... the problem I'm dealing with now is that all my projectiles that have been previously despawned and respawned are all stopped. I'm trying to find a way to keep em going when they respawn LOL.
The Start() in my missile move script sets the velocity. When they go off screen for a while they get despawned and sent to the Pool Boss, which is good. Then when I shoot a missile that was recylced, it's stopped. I tried tracing the code for Spawn/Despawn and can't figure out what is setting the velocity to zero. Seems like I'm going against the grain since you recently wrote some velocity resetting code from what I see. Any advice would be appreciated.
|
|
DarkTonic Dev
Administrator
Posts: 4,229
Posts: 4,229
Member is Online
|
Post by DarkTonic Dev on Jul 25, 2014 16:39:23 GMT
Ok, I'll fix the reset velocity code to work on 2d rigidbodies too.
As far as the missile, I don't believe the velocity is getting reset any more by CGK. It might be that 2d stuff automatically stops velocity when turned inactive (despawned). You can try moving the "set velocity" code you have from Awake into OnSpawned so it will happen every time it's spawned.
|
|