Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: 2h on June 07, 2016, 06:58:03 PM
-
Hi all, I'm new to Playmaker and would associate some advice.
I simply want to instantiate a prefab and have force immediately applied to it. So for insurance it could be a Canon ball firing from a Canon.
So far I have a mouse click event to trigger, a prefab instantiating, but I'm not sure how to adult force to the prefab.
Any suggestions appreciated.
2h
-
Create an fsm on the canon ball that has the "Add Force" action- just make sure it has a collider and a rigid body component as well-
-
Hi, thanks for the reply.
I have tried this, but no look getting the force to apply.
I was also thinking the following.
To the projectile object I had added the actionaddForce and also a listener for a mouse click. This meant every instantiation of the projectile had these components.
I was thinking, is it better to have a listener on the canon. When the button clicks, a child object (projectile) is created and is launched with force. This was what I had in mind, but I can't manage to transfer my logic to a playmaker state. I can;t get the force to apply to the projectile.
Any more advice would be appreciated.
2h.
-
Okay, I have it firing now.
I'll attach an image of the State machine, might be of use to another.
The next thing I want to do is have the force match the direction that the canon points.
Following that, a dynamic way to vary the force.
Thanks for the help so far. Any other suggestions or tips appreciated.
2h.
-
When your cannon ball spawns it should do so with the same x,y,z orientation as the object it's spawning on. it's just a matter of adding the force in the correct orientation.
Z+ is usually the preferred axis for forward movement. I see from your pic your force is going in the Y axis. You can modify the rotation at spawn by opening up the "rotation" section of the create object action.
Below is a pic of the deck cannon system on my submarine. It doesn't need any special rotation because the cannon bore is oriented with Z pointing forward just like my cannon shell.