Oshigawa
Full Member
Posts: 228
Posts: 228
|
Post by Oshigawa on Feb 4, 2016 10:20:53 GMT
Hello,
i wrote to you on the email yesterday, but we didn't understand each other due to terminology differences. I checked the forums, but i haven't found the solution, but the problem is pretty straightforward, so i hope you can help.
Anyway, here's what's going on.
I created a spawner that churns out prefab Enemy and that's working fine. Also, the hitpoint feature on Killable script is working fine and the Enemy gets despawned or not depending on the Bullet's attack points.
The thing that i can't make to work is to destroy the Bullet on collision with the Enemy.
I've added the Killable script on the Bullet prefab, but when i hit play it says that it is despawned and inactive. I get that, it wasn't spawned through the CGK spawner, but how come can i alter the Bullet's attack points and they affect the enemy accordingly? And if the Bullet affects the Enemy, how come doesn't the Enemy affects the Bullet?
I've tried setting the HP Death Mode on the Bullet prefab to Collision or Trigger - nothing happens.
Also, when i make an FSM for the Bullet prefab to destroy itself on collision then the Enemy gets despawned by one shot, no matter how high i set the hitpoints.
Edit: i snooped around the forum a bit, took a look at some of the other topics, i will try to spawn Bullet through Spawner.
|
|
|
Post by DarkTonic Dev on Feb 4, 2016 17:00:29 GMT
You're going to have to send me a project that reproduces the problem. Please see the official bug reporting thread stickied here.
Or, turn on logging for the bullet Killable and it will probably tell you what's wrong in the console. It's not required to use spawners by the way. Again, there's no point trying to solve the problem with Playmaker. It will fail for the same reason, whatever it is.
|
|
Oshigawa
Full Member
Posts: 228
Posts: 228
|
Post by Oshigawa on Feb 4, 2016 18:40:48 GMT
Ok, i'll check out the console. I will also make a regular Bullet script, not through Playmaker, to see if the problem still occurs.
|
|
|
Post by DarkTonic Dev on Feb 4, 2016 19:43:57 GMT
Sounds good.
|
|
Oshigawa
Full Member
Posts: 228
Posts: 228
|
Post by Oshigawa on Feb 6, 2016 0:07:14 GMT
Ok, i've made a simple project without playmaker, basic stuff, scripts for moving the Player and Enemy, Shot script for the Bullet and Weapon script for shooting, added the Enemy and Bullet prefabs to the pool etc. And the problem remains. The Enemy reacts great to the Bullet, if it has HP of 2, it takes two shots to despawn it. Unfortunately, the Bullet does not despawn by collision. The thing is, when i put the Bullet in the scene, everything works as it should, it hits the Enemy, both despawn. But when i fire (instantiate the shot via weapon script) it acts differently, i.e. does not despawn. However, i noticed that the instantiated Bullet is CLONE, and is not considered as being from the pool since i get the following message in the console: The Transform 'Shot(Clone)' passed to Despawn is not in Pool Boss. Not despawning. You can check out the project here: www.dropbox.com/s/pxdara5ga7raq9c/CG%20Kit%20proba%20killable%20skripte.rar?dl=0I don't think there's a bug here, i just don't know why my Bullet is instantiated as a clone (i'm kinda new to Unity, i don't know if the instatiation from prefab makes a clone by default or not).
|
|
|
Post by DarkTonic Dev on Feb 6, 2016 0:15:24 GMT
Aha. The problem is that you're Instantiating the bullet. You should never Instantiate *anything* that is Killable or that spawns from spawners when using Core GameKit. You should only spawn and despawn via PoolBoss. Everything depends on PoolBoss. So, make sure you have put the "Shot" prefab in PoolBoss, then call PoolBoss.Spawn instead of Instantiate (which is many many times better for performance). That will be working now.
Whether Instantiating or Spawning, the word Clone will be on there, but the spacing will be slightly different. That's normal.
|
|
Oshigawa
Full Member
Posts: 228
Posts: 228
|
Post by Oshigawa on Feb 6, 2016 13:12:44 GMT
Thanks, i'll give it a shot. Sorry for bugging you, haven't done the pooling stuff before. I'm sure this come in handy for many beginners.
|
|
|
Post by DarkTonic Dev on Feb 6, 2016 18:29:45 GMT
Sure thing! Pooling is absolutely vital for performance.
|
|
Oshigawa
Full Member
Posts: 228
Posts: 228
|
Post by Oshigawa on Feb 8, 2016 10:13:13 GMT
Another day, another challenge! I hope it's ok to post it here, i don't want to clutter the forum with topics. Not sure if this is the right place to post the problem, since it involves Playmaker, but it also involves one of your actions. I posted the same thing on the Playmaker forum, here it goes here too: On the first picture we have a very simple FSM attached to the Player object. I am using actions from Core Game Kit for pooling objects. In this case, by pressing key, a shot is spawned from the spawner object attached to the player object, and whenever the player moves, the bullet spawner moves with him. I just dragged and dropped the bullet spawner from the scene to the "other object for position" box, and everything works fine. In the next picture, i am doing something similar for the Enemy object, but something's not working right. I created the Enemy, spawner object for him to shoot from, and simple FSM to spawn bullets every second. Here comes the problem, i can't drag and drop the spawner object from the scene directly into the "other object For Position" box (i get the menu in the picture with options to get or set property), only from the prefab folder, but then the bullets are spawned right in the middle of the screen, not from the spawning object attached to the enemy object. Here's another picture to better show you what's going on:
|
|
|
Post by DarkTonic Dev on Feb 8, 2016 16:26:08 GMT
Yeah that's a limitation of Unity. It won't allow you to use another object in the Scene for that, so the get/set pops up. You will be able to use another game object in the same prefab but not anything else.
However, there's another way to do this. Don't make a bullet spawner prefab. Just add a Triggered Spawner component to the enemy (and to the player), and call its method "ActivateCodeTriggeredEvent1" after setting up a wave for CodeTriggeredEvent 1 on it. Playmaker can call that method.
|
|
Oshigawa
Full Member
Posts: 228
Posts: 228
|
Post by Oshigawa on Feb 12, 2016 12:06:36 GMT
Ok, i'll try that, thank you
|
|
|
Post by DarkTonic Dev on Feb 12, 2016 18:19:06 GMT
No problem.
|
|
Oshigawa
Full Member
Posts: 228
Posts: 228
|
Post by Oshigawa on Feb 19, 2016 14:28:32 GMT
For god's sake, i don't know what am i doing wrong. Here is the triggered spawner i attached to the player prefab, set to spawn a shot prefab: When i try to call the method ActivateCodeTriggeredEvent1 from playmaker, i get nothing, i don't know how to set the behaviour. Also, triggered spawner is despawned and inactive. I can't drag triggeredspawner script to behaviour box.
|
|
|
Post by DarkTonic Dev on Feb 19, 2016 16:23:53 GMT
If you took a screen shot from Play mode, then there's no way it's going to work since your player is despawned (that's why the red message).
Anyway, you still need to drag the TriggeredSpawner component into the "Behaviour" box above where you typed ActivateCodeTriggeredEvent. Otherwise, Playmaker doesn't know what C# class to call the method on. That's why it says "Behaviour is invalid!".
|
|
Oshigawa
Full Member
Posts: 228
Posts: 228
|
Post by Oshigawa on Feb 19, 2016 18:05:00 GMT
Sorry, it wasn't in the play mode, it's spawned. Yeah i know, the trouble is i get the get/set popup when i drag the script over. I'll check out playmaker forums once more, there's been talk of the problem when FSM is loaded from template, i have to make sure that is solved.
|
|