playMaker

Author Topic: Add Force Local *2d Physic*  (Read 3696 times)

VictorRayDev

  • Playmaker Newbie
  • *
  • Posts: 35
Add Force Local *2d Physic*
« on: November 10, 2014, 10:41:25 AM »
Hi!
I'd need this action please.
http://docs.unity3d.com/ScriptReference/Rigidbody2D.AddRelativeForce.html

Currently the addforce 2d is not relative to the rotation of the object.

I'm doing a little 2d golf game and I'd need to add the force relatively to the rotation of the ball.
Maybe it is already possible but I don't see a way to do it.

Thanks guys!  8)

nick_h82

  • Playmaker Newbie
  • *
  • Posts: 36
Re: Add Force Local *2d Physic*
« Reply #1 on: November 10, 2014, 02:33:57 PM »
Hi,

I solved this with the trig actions- not exactly what you're asking but it would be a solution:
 
http://hutonggames.com/playmakerforum/index.php?topic=5677.msg27322#msg27322

Cheers,

Nick

VictorRayDev

  • Playmaker Newbie
  • *
  • Posts: 35
Re: Add Force Local *2d Physic*
« Reply #2 on: November 10, 2014, 02:40:35 PM »
it is a little bit complex for something to be so simple via local force :P.

I'm going to give your technique a go.

nick_h82

  • Playmaker Newbie
  • *
  • Posts: 36
Re: Add Force Local *2d Physic*
« Reply #3 on: November 10, 2014, 02:59:09 PM »
Yeah- it is fairly complex, but in the end neater than trying to make the rotation do what you'd want. I would guess you're only applying the force for one frame when you hit the ball, otherwise be sure to run the trig equations every frame if you're varying the angle or force.

VictorRayDev

  • Playmaker Newbie
  • *
  • Posts: 35
Re: Add Force Local *2d Physic*
« Reply #4 on: November 10, 2014, 04:17:30 PM »
Thanks Nick! Followed your instruction work perfectly!

nick_h82

  • Playmaker Newbie
  • *
  • Posts: 36
Re: Add Force Local *2d Physic*
« Reply #5 on: November 10, 2014, 05:11:21 PM »
Cool, glad to hear!