Oshigawa
Full Member
Posts: 228
Posts: 228
|
Post by Oshigawa on May 9, 2016 13:53:23 GMT
Hi again,
there's a thing i'm missing in the killable script, and that's how much damage will the object take from a differently tagged object, in other words, a bullet from a different weapon. It's not a problem for me to create a health script that i will atach to the enemy that will compare the colliding object and substract the health from the enemy. The thing is, will it mess with the killable script if i set the death hp mode to none? If it will, is there a workaround?
IThe other thing is, if it won't, how will i call despawn from the health script that will be atached to the enemy? I see in the manual that i should call the DespawnKillable method, but it's nowhere to be found in the script.
|
|
|
Post by DarkTonic Dev on May 9, 2016 15:44:14 GMT
I wouldn't do any of that. If you already have another prefab with a different tag, give it different attack points.
|
|
Oshigawa
Full Member
Posts: 228
Posts: 228
|
Post by Oshigawa on May 10, 2016 9:49:10 GMT
Sounds good, but the thing is, i've set the bullet prefab's killable attack points to one, and the enemy's killable hit point to 30 and it takes 3 shots to despawn it. When i set it to 10 it requires 1 hit etc. I mean, it's not a problem, but that's not the way it's supposed to be
|
|
|
Post by DarkTonic Dev on May 10, 2016 16:02:53 GMT
I have no idea how that is happening. You would need to send me a project to debug.
|
|
Oshigawa
Full Member
Posts: 228
Posts: 228
|
Post by Oshigawa on May 10, 2016 18:47:51 GMT
Sure, i'll upload it.
|
|
|
Post by DarkTonic Dev on May 10, 2016 19:17:56 GMT
Sounds good
|
|
Oshigawa
Full Member
Posts: 228
Posts: 228
|
Post by Oshigawa on May 12, 2016 10:18:43 GMT
Here it is, sorry for waiting. It's uploading at the moment, it will up in about an hour or two.
I've sent it to your PM.
The Killable Listener is making a problem, i don't know what i'm doing wrong. Without it, everything works as intended.
Here's what i did:
1. Attach Killable Listener to the Enemy1 prefab and name the Source Killable Name Enemy1. 2. Make the necessary modifications to the Killable Listener Script:
public virtual void Despawning(TriggeredSpawner.EventType eType) {
GameObject AudioSource = GameObject.Find("AudioSource");
AudioSource audiosource = AudioSource.GetComponent<AudioSource>();
GetComponent<AudioSource>().Play();
{
}
}
public virtual void Despawned() {
GameObject ScoreController = GameObject.Find("ScoreController");
ScoreController scorecontroller = ScoreController.GetComponent<ScoreController>();
{
scorecontroller.AddScore(5);
scorecontroller.UpdateScore();
}
} 3. Drag the Killable Script to the Listener field under Immediate Actions tab of the Enemy1 prefab.
Log says this: Not taking any damage because you've collided with non-Killable object 'BulletPrefab(Clone)'. Bullet Prefab has Killable script attached but spawns from another pool. Also, for the Enemy1 prefab it says Despawned and inactive, i don't know why, i've set it up many times before.
One more question, i know it's kinda unappropriate to ask this here since this is only plugin related forum, but is it possible to make an editable field out of AddScore in the inspector of the Killable Listener so i don't have to edit the script every time for a different enemy? If anyone has some patience for it i would be very grateful.
|
|
|
Post by DarkTonic Dev on May 12, 2016 19:43:10 GMT
Before I download this, please answer these questions / observations:
1) Do you really have a Game Object called "AudioSource"? Or were you looking to play the audio on a sub-game object of the Killable? 2) You don't have to type the name of the Killable you're listening to. That field is for your reference only and gets filled out when you attach. 3) The logs do not lie. If it says BulletPrefab has no Killable then it does not. Perhaps the Killable script is on a sub-game object instead of top-level? 4) Prefabs in Project view are despawned and inactive. Spawned instances in the Scene are not. 5) You can add your own public int variables to KillableListener (or any others) yourself and use them. Note that you should make a subclass of KillableListener for each enemy (and other Killables) so you can change that variable per prefab and not need to edit the script.
|
|
Oshigawa
Full Member
Posts: 228
Posts: 228
|
Post by Oshigawa on May 13, 2016 13:48:18 GMT
Before I download this, please answer these questions / observations: 1) Do you really have a Game Object called "AudioSource"? Or were you looking to play the audio on a sub-game object of the Killable? 2) You don't have to type the name of the Killable you're listening to. That field is for your reference only and gets filled out when you attach. 3) The logs do not lie. If it says BulletPrefab has no Killable then it does not. Perhaps the Killable script is on a sub-game object instead of top-level? 4) Prefabs in Project view are despawned and inactive. Spawned instances in the Scene are not. 5) You can add your own public int variables to KillableListener (or any others) yourself and use them. Note that you should make a subclass of KillableListener for each enemy (and other Killables) so you can change that variable per prefab and not need to edit the script. 1) Nevermind that, i deleted it. 2) Ok, got it. 3) The logs were true indeed, the Killable was on the wrong prefab. 4) Ok 5) Thanks, i'll figure it out, just needed a starting point Helpful as always, have a nice weekend!
|
|
|
Post by DarkTonic Dev on May 13, 2016 15:45:47 GMT
Awesome, glad it was some help.
|
|