|
Post by frostamation on Jan 12, 2015 1:46:40 GMT
So i have a bullet that gets created when player fires, when i use the "create object" it fires in the correct direction( the direction the muzzle is facing). Now when i use the pool spawn, which i need to for pooling, when the bullet spawns it is always looking in the z axis(the z axis is the axis that the force is applied to). In the image you will see the settings i am using for the old create object which work and the new pool spawn which doesnt work yet. I have tried all the combinations i can think of with the same result happening each time. image doesnt seem to be working so here is the link imgur.com/lgW4tPf
|
|
|
Post by DarkTonic Dev on Jan 12, 2015 2:49:48 GMT
From the image, I believe you need to set Rotation Mode to "Custom Euler" (not Identity). Then when it spawns it will use the Euler Rotation X,Y,Z under that for the rotation. If you set that to the rotation of the spawner, it should work.
Or, if you used a Triggered Spawner component to spawn the object, it has another option for Spawn Rotation Mode of "Use Spawner Rotation". If you set up the Triggered Spawner and use its events instead that may be easier for you.
|
|
|
Post by frostamation on Jan 12, 2015 22:27:09 GMT
trying to setup using a triggered spawner since im still having issues with the custom euler, made progress but figured id give the trigger a shot.
So after i put the triggered spawner script on player i look in the event activate dropdown and i dont see a lot of what is mentioned in the manual. such as PointerDown(ugui). i switched to legacy and i get a mouse click, so im currently using that.
With that done nothing is actually happening, the spawn object isnt spawning. Im trying to keep it the same as i had it which is the players mouse is where the bullet will shoot, which is setup, and the bullet spawns from the players muzzle location, which is setup. Now just need to figure out how to get the triggered spawner to actually spawn on the mouseclick trigger. Any help appreciated.
issue with the euler incase that one ends up being a better/easier/efficient option. I have a new FSM on the player that will take the rotation of the muzzle and set it as a global vector3 then i use that global v3 and tell the pool boss spawn to spawn the bullet at the muzzle with the euler rotation. Half the time it works the other half it doesnt, and if the mouse is infront of the player the bullet spanws and explodes right in front of player. Looking to the left/right the bullet fires outward as intended half the time the other half time it seems to stray in a random direction, maybe the global v3 variable is messing up randomly, but i didnt see anything of that going on when investigating.
Edit 1#: I also get the error: *cannot propagate events with no child spawners inside the triggered spawner script, dont know whats causing it but no matter what i select/chose i cant ever seem to get it to go away.
|
|
|
Post by DarkTonic Dev on Jan 13, 2015 0:06:39 GMT
Watch the video here www.youtube.com/watch?v=1O6M3V8syXg&list=PLW6fMWQDKB24osBmTuJd0IG8R5tOim6eV&index=10. The uGUI stuff only shows up if you have a RectTransform component on the same game object (otherwise nothing could trigger it). I'm not sure if your wave is actually trying to spawn or not (failed mouse click somehow?). MouseClick means you have to click right on the game object. I don't think you really want it to happen on MouseClick anyway. You can set up a wave to spawn with "Code-Triggered Event 1" and then fire that from code (call ActivateCodeTriggeredEvent1 method on the TriggeredSpawner). "Cannot propagate" is not an error. It's yellow. Errors are red. Yellow are just important warnings. It sounds like possibly your bullet model has a center point that's not actually at its exact center? In which case rotating it may actually make it move visually. If that's the case, it will have the same problem with Triggered Spawner. You can test this while in Play mode in the editor and making the bullet not move after spawned temporarily.
|
|
|
Post by frostamation on Jan 13, 2015 18:42:35 GMT
Im trying to get the triggededevent1 to work, is there a way to call it from playmaker? I have tried the "cgk fire custom event" from inside playmaker but it requires a custom event name to which I have tried many things with no success. Is there a way to name the "triggeredevent1" to something so i can call it using the "fire custom event"?
|
|
|
Post by DarkTonic Dev on Jan 13, 2015 23:37:38 GMT
Yeah there is a way, use the normal "Call Method" action included with Playmaker. You don't need the CGK actions for this. Call ActivateCodeTriggeredEvent1 method on the Triggered Spawner.
Custom Events are different. You could use those also if you wanted. Read about Custom Events in the readme if you're curious (that section is only a page or 2). Firing a Custom Event means any number of Triggered Spawners can respond to that event. You have to create them first in the LevelWaveSettings game object (last section).
|
|
|
Post by frostamation on Jan 14, 2015 0:20:25 GMT
got the call method working thanks for the help on that. I have a new problem now that i thought was something else that i could fix but turns out i dont see how to do it.
When the bullets are created they have a "add force in x amount in y direction" to them, once they despawn with the poolboss and get reused again their force in y direction is still going and so when looking left and firing then looking right and firing the bullet from the second shot is still moving in the previous y direction because it still has that force applied to it. is there a way to reset the bullets each time they are despawned with the poolboss?
|
|
|
Post by DarkTonic Dev on Jan 14, 2015 0:37:48 GMT
Actually Killable has this code built in, for the OnDespawned event:
if (this.Body != null && this.Body.useGravity && !this.Body.isKinematic) { this.Body.velocity = Vector3.zero; this.Body.angularVelocity = Vector3.zero; }
So it's already doing what you want. But this only works if the RigidBody is in the same Game Object as the Killable (which it needs to be to work properly for damage). If you have the Rigidbody in a child object, that won't work. If you do have it in the same Game Object, then you're seeing a bug of some sort and I'll need you to send something that reproduces the bug.
Notice that the code only fires if the RigidBody is Gravity and not Kinematic.
|
|
|
Post by frostamation on Jan 14, 2015 19:27:07 GMT
ah i took off the rigidbody has gravity, once i turned it back on it seems to have fixed it now! woot! have another question but i'll post up a new topic to keep this one clean incase anyone else needs this info.
|
|
|
Post by DarkTonic Dev on Jan 15, 2015 1:17:20 GMT
I don't think adding force to a non-gravity rigidbody does anything, does it?
|
|
grahamh
New Member
Posts: 4
Posts: 4
|
Post by grahamh on Nov 11, 2015 14:48:10 GMT
Actually Killable has this code built in, for the OnDespawned event: if (this.Body != null && this.Body.useGravity && !this.Body.isKinematic) { this.Body.velocity = Vector3.zero; this.Body.angularVelocity = Vector3.zero; }
So it's already doing what you want. But this only works if the RigidBody is in the same Game Object as the Killable (which it needs to be to work properly for damage). If you have the Rigidbody in a child object, that won't work. If you do have it in the same Game Object, then you're seeing a bug of some sort and I'll need you to send something that reproduces the bug. Notice that the code only fires if the RigidBody is Gravity and not Kinematic. I don't want gravity applied to the prefab that I'm using as a projectile. As a result, I've used 'set velocity' on the projectile since I can't add force to it. Just wondering - since I have used 'set velocity', rather than 'addforce' can I simply comment out the '&& this.Body.useGravity'. within Killable? Or perhaps it could be added as an option for awkward people like me?
|
|
|
Post by DarkTonic Dev on Nov 11, 2015 16:28:04 GMT
You can comment out whatever you like, but next time you update the plugin, your changes will be overwritten.
Let me know what you end up changing and we'll consider adding it as an option.
|
|
grahamh
New Member
Posts: 4
Posts: 4
|
Post by grahamh on Nov 11, 2015 19:43:48 GMT
Okay, I made the edit so that the code segment within Killable.cs (listed above) now reads:
if (this.Body != null && !this.Body.isKinematic) { this.Body.velocity = Vector3.zero; this.Body.angularVelocity = Vector3.zero; }
This has solved the problem for me but...
As you said, that will work until an update is applied.
Is there a simple way to make the code unique so that it doesn't get replaced?
I guess it's not a simple case of renaming the file to something like Killable_noGravity since the namespace will also need changing and it will likely mess up other elements of the script.
All help greatly appreciated.
|
|
|
Post by DarkTonic Dev on Nov 12, 2015 6:12:06 GMT
Okay, I made the edit so that the code segment within Killable.cs (listed above) now reads: if (this.Body != null && !this.Body.isKinematic) { this.Body.velocity = Vector3.zero; this.Body.angularVelocity = Vector3.zero; } This has solved the problem for me but... As you said, that will work until an update is applied. Is there a simple way to make the code unique so that it doesn't get replaced? I guess it's not a simple case of renaming the file to something like Killable_noGravity since the namespace will also need changing and it will likely mess up other elements of the script. All help greatly appreciated. First of all, you're not on the latest version of the code (the code you're showing is out of date). If you would first get the latest version and make your changes there, then let me know what they are, I will again consider to make it compatible with the core version. Thank you.
|
|
grahamh
New Member
Posts: 4
Posts: 4
|
Post by grahamh on Nov 13, 2015 0:59:22 GMT
Thanks for the heads up about not having the latest code. Thought I had the latest version but it hadn't installed properly.
Finally got it sorted.
I took a look at the latest version of Killable.cs and found ResetVelocity().
Commented out the test to see if the body has gravity applied.
private void ResetVelocity() { /* if (!IsGravBody) { return; } */ if (Body != null) { Body.velocity = Vector3.zero; Body.angularVelocity = Vector3.zero; }
This works for what I need. Not expecting you to make changes to your code just for my benefit though.
Thanks - love the asset
|
|