playMaker

Author Topic: Flying a missile from a Submarine. (Parabola Arc)  (Read 10496 times)

pdunton

  • Playmaker Newbie
  • *
  • Posts: 35
Flying a missile from a Submarine. (Parabola Arc)
« on: July 22, 2013, 08:54:00 PM »
I simply wish to create a script where when i click, it sends a missile in the direction I am looking. Then, I will use Is Trigger to trigger an explosion.  Just the explosion graphics will do so don't worry about that.  But the Arc is killing me.
Thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Flying a missile from a Submarine. (Parabola Arc)
« Reply #1 on: July 29, 2013, 05:38:37 AM »
Hi,

 you need to use physics for this, have you experiemented with physics already?

Look at this example, it has a custom action "Physics Shoot" that will likely help you.

http://hutonggames.com/playmakerforum/index.php?topic=2373.msg10514#msg10514

bye,

 Jean

pdunton

  • Playmaker Newbie
  • *
  • Posts: 35
Re: Flying a missile from a Submarine. (Parabola Arc)
« Reply #2 on: August 03, 2013, 10:04:41 PM »
Ok so I got the Physics Shoot, and yes it is looking promising.  But, I have no idea on how to use it.  I will shoot the missile, with no target in particular, from the sub.  Sorry!
Thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Flying a missile from a Submarine. (Parabola Arc)
« Reply #3 on: August 05, 2013, 06:33:39 AM »
Hi,

 then, you simply need to use the AddForce action to the missile itself, that will work just fine.

bye,

 Jean

pdunton

  • Playmaker Newbie
  • *
  • Posts: 35
Re: Flying a missile from a Submarine. (Parabola Arc)
« Reply #4 on: August 07, 2013, 08:42:41 PM »
I am brand new to Playmaker, and I don't know what to do.  I can add the action to my script, but nothing past there because I  don't understand.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Flying a missile from a Submarine. (Parabola Arc)
« Reply #5 on: August 08, 2013, 04:41:01 AM »
Hi,

 ok, I have created a small sample.

to fire, I simply use "Add force", that's enough to propel a physics gameobject.

in our case, I went further. I made it so that it follows the trajectory for realism. to do that in its most simplistic form, I had to tweak the missiel gameObject to fire on its z axis, but because the capsule is not aligned with the z axis, I made it as a child of the missile, where the missile only has a capsulde collider.

this setup is really optimal in may ways, because you can then have any kind of shape for your missile mesh, as long as it's along the z axis. and you don't need to have complex colliders, simply rely on the capsule collider ( a box collider would do fine here f the missile is to dissapear on hit.

bye,

Jean

Red

  • Hero Member
  • *****
  • Posts: 563
Re: Flying a missile from a Submarine. (Parabola Arc)
« Reply #6 on: August 09, 2013, 04:18:31 PM »
The physics shoot action is definitely where i'd suggest heading too...

If you're having some trouble, first off make sure the rigid body that you're using on the item you wish to fire has the appropriate mass and gravity added to it... since this will affect how it sails through the air.

From there, you can have the action either on the projectile itself or on the launcher... afaik it doesn't really matter which so this might be best left to your personal preference. then you choose either the range/distance you want it to go from the spawn point or the location as an object (the target) you want it to hit. This will calculate all of this based on the origin/pivot of the objects so you're going to need to keep that in mind.

So, the process I have in my own systems (for thrown weapons... they follow the arc though) is i spawn the object (well, i fetch it from the pool but that's my own thing) then i place it where the spawn point is to be... then i apply the force needed at an angle i've defined to get the trajectory and the grenade is then given the appropriate force needed for it to sail through the air and land where i need it to at the initial angle determined by you... the action seems to need the angle and either the target as an object or the distance you want it to travel... so, if you're having difficulties, maybe make sure you're giving it only two pieces of data (as all three pieces might be too much for it to handle... though i haven't really tried pushing it that far so i'm not 100% sure of that.)

Past that, the rotation is not controlled, just the force... so if you want the missile to have a nice rotation to it, you might want to consider something more... like I said, i use this for little things like grenades, flashbangs and the like so they're small and aren't really bothered by rotation.

pdunton

  • Playmaker Newbie
  • *
  • Posts: 35
Re: Flying a missile from a Submarine. (Parabola Arc)
« Reply #7 on: August 13, 2013, 04:21:15 PM »
Ok, I got confused, oh so confused, and tried a couple things.  None of them worked.  And I got the example Jean posted but it had no scripts. ?
I found an example of what I want.  This is exactly what I want.

http://www.dreamquestgames.com/camp/InTheShadows.html

Hit spacebar to start the game, and right click to shoot the light capsule.  BTW that game was made in two weeks.  I also will attach my scene so that way you can all see it.  Feel free to explore, and try scripts, and if you find something that works like the example I posted, repost it so I can see the script.  Thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Flying a missile from a Submarine. (Parabola Arc)
« Reply #8 on: August 14, 2013, 03:11:10 AM »
Hi,

 why do you want scripts? Can you operate the missile? I guess your problem is more on how to manage missiles to fire them when you click right?

 Can you explain where you are confused? that will allow me to fine tune my explanations.

bye,

Jean

pdunton

  • Playmaker Newbie
  • *
  • Posts: 35
Re: Flying a missile from a Submarine. (Parabola Arc)
« Reply #9 on: August 14, 2013, 04:57:45 PM »
By no scripts, I meant that when I hit play, the missile just simply fell over.  Nothing happend, in other words.  And my confusion comes in two forms.  What is up with the z axis thing?  And how do I get addforce to add force in the direction I'm looking?  I can get the missile to fire in one direction using specific values in addforce, but not any nonspecific.  Sorry, I seem to be dragging on a simple answer.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Flying a missile from a Submarine. (Parabola Arc)
« Reply #10 on: August 15, 2013, 02:56:50 AM »
Hi,
 
Ok, I doubled checked the package. The only way I can recreate this situation is if PlayMaker is not installed in your project.

 Can you open the scene, select the gameObject "Missile" and open the Fsm "Missile".

 If indeed you have the Fsm "Missile". do you have any errors in the console of Unity or PlayMaker?

 I tried on 3.5 and 4.2 with the latest version of PlayMaker from the asset store.

We'll get to the bottom of this :)

 Bye,

Jean

pdunton

  • Playmaker Newbie
  • *
  • Posts: 35
Re: Flying a missile from a Submarine. (Parabola Arc)
« Reply #11 on: August 15, 2013, 07:21:17 PM »
I selected the gameobject Missile, but No scripts were attached. Ill post a screenshot of its Inspector, but it is a plane capsule. I have Playmaker,  I got the tab, and can edit FSMs and all of it.  Im not sure what version of playmaker I have now or if i need to update.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Flying a missile from a Submarine. (Parabola Arc)
« Reply #12 on: August 16, 2013, 04:48:37 AM »
Hi,

 Can you do that on a fresh project? You should always update to the latest playmaker anyway ( after a proper backup as always)

bye,

Jean

pdunton

  • Playmaker Newbie
  • *
  • Posts: 35
Re: Flying a missile from a Submarine. (Parabola Arc)
« Reply #13 on: August 16, 2013, 01:06:33 PM »
I don't know how to update, when I look at any playmaker item on the asset store it says I still have to buy it.  This is becuase I recently attended a camp on unity and the owners of the camp bought playmaker for everyone and flash drives it over.  This sure is going a lot farther than the missile lol.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Flying a missile from a Submarine. (Parabola Arc)
« Reply #14 on: August 19, 2013, 03:57:55 AM »
Hi,

 uhm.. That's not really allowed, Unless he had a deal with PlayMaker. Basically, a PlayMaker license is per seat. so you should buy it for yourself really.

bye,

Jean