playMaker

Author Topic: Another Add Force question (SOLVED)  (Read 2417 times)

snortch

  • Playmaker Newbie
  • *
  • Posts: 31
Another Add Force question (SOLVED)
« on: August 01, 2014, 12:34:59 PM »
In searching around on the forum, I can see quite a few questions about the Add Force action and I have another.

I am trying to recreate the Will Goldstone tutorial from his book "Unity 3.x Game Development Essentials". It's the first walkthrough in that book where you make a wall and throw a sphere at it. I was able to get this tutorial to work ok in code, but didn't really understand what I was doing. I decided to see if I could figure out how to do it in Playmaker. I think my problems revolve around the Add Force action. I don't think I'm understanding how Unity adds force to things.

I made a video that shows what I've done so far:
http://www.screencast.com/t/ALeNgxlTrC2j

Would really appreciate any suggestions on getting this to work correctly.

TIA,
Dan
« Last Edit: August 01, 2014, 03:34:52 PM by snortch »

MajorIdea

  • Full Member
  • ***
  • Posts: 131
Re: Another Add Force question
« Reply #1 on: August 01, 2014, 02:06:52 PM »
Maybe try to Store the Object you created on the CreateObject action and then add force to that object (making sure you're adding force to the object you created and not the original one)

Or you could try adding the AddForce to the bullet itself.

snortch

  • Playmaker Newbie
  • *
  • Posts: 31
Re: Another Add Force question
« Reply #2 on: August 01, 2014, 03:10:07 PM »
@MajorIdea:

Ok, so I tried your first idea (using "Store the Object" in the CreateObject action) and it totally worked, thank you! I don't understand why this works?

I don't think I have tried your 2nd suggestion, but you can see at 2:08 in my vid, I mentioned that I am using AddForce and the Game Object I'm specifying is the "Bullet" prefab. Is that not the right way to AddForce directly to the bullet itself as you suggested?

Thanks again for helping with this

MajorIdea

  • Full Member
  • ***
  • Posts: 131
Re: Another Add Force question
« Reply #3 on: August 01, 2014, 03:20:03 PM »
Haha I'm not entirely sure either, but my guess is that you were trying to add force to the original bullet (the one you selected to create the other bullets).

As for the other way of doing it - it's merely the difference between the gun telling the bullet what to do, and having the bullet know what needs to be done when it's spawned. In this case I think it's essentially the same thing.
But if it was a rocket you were spawning I'd say it would make sense to have the rocket add it's own force that you can then control and have it follow a target for example.

Anyway, glad it worked.  :)

snortch

  • Playmaker Newbie
  • *
  • Posts: 31
Re: Another Add Force question
« Reply #4 on: August 01, 2014, 03:34:06 PM »
This video also suggests applying AddForce to the projectile itself ( at :30):


It makes more sense to me why Add(ing)Force to the projectile itself would work, its just requiring me to rewire my brain a little to think this way because it seems more intuitive to me to add force to the projectile after I've fired it.

Anyway - thanks again