playMaker

Author Topic: Add Force Towards Object  (Read 3051 times)

jasperPT

  • Full Member
  • ***
  • Posts: 115
  • I am a VFX Animator teaching myself to make games
Add Force Towards Object
« on: April 07, 2014, 11:48:16 AM »
Hi,
I am trying to create a tractor beam type situation, that can have multiple beams pulling on an object at the same time.

The method I am going about it by is to try and raycast from my "gun" to the object, then adding a negative force at the point which my ray hits.
However I dont seem to have an option to raycast towards an object.

Is this the right way to go about doing something like this?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Add Force Towards Object
« Reply #1 on: April 08, 2014, 07:03:39 AM »
Hi,

 simply define yourself the direction of the raycast. Use "transform direction" to get the direction from a gameobject to point where ever you need from that object local reference.

bye,

 Jean

jasperPT

  • Full Member
  • ***
  • Posts: 115
  • I am a VFX Animator teaching myself to make games
Re: Add Force Towards Object
« Reply #2 on: April 09, 2014, 08:50:00 AM »
Hi Jean

Thanks for the help but it doesn't make any sense to me.

I don't know what the direction is that I need to point in, and that is what will change every frame.
Transform Direction asks for a "Target direction" which is what I assume is the direction of the object im trying to point my raycast at? It needs a vector 3 which makes sense but I have no way of figuring out what that vector 3 needs to be.


sebaslive

  • Hero Member
  • *****
  • Posts: 572
    • Frame Tale Studios
Re: Add Force Towards Object
« Reply #3 on: April 09, 2014, 12:20:19 PM »
Animators gotta look out for one another :D and awesome work with the ninja turtle animation!!

I plan on using something like this in my own game but carrying a bunch of more cows at once so it's not just one by one BUT I think this will be a good start for whatever you need. At the very least, answer the question here.

If you have any questions about the scene or would be interested when I get the multiple carries set up just let me know!

Note: Play the scene and translate the alien ship left and right to target the cows. Rotate the ship to get the cow to go in the direction of the ship. Play around with the addForce to get it at the speed you want.
« Last Edit: April 09, 2014, 12:21:58 PM by sebaslive »
All my VR games use Steam VR Playmaker Toolkit: http://u3d.as/u20
And Oculus Touch Playmaker Toolkit: http://u3d.as/QT5


Follow me @sebasRez

jasperPT

  • Full Member
  • ***
  • Posts: 115
  • I am a VFX Animator teaching myself to make games
Re: Add Force Towards Object
« Reply #4 on: April 11, 2014, 05:01:51 AM »
Thanks Sebaslive.

Glad you liked the turtles animation :)

I took a look at your scene, and while it goes part way to answering my question, what i need is for an object to constantly be in motion while getting beamed towards a target via force. And I will have several tractor beams applying force to it so that basically you have a tug of war type mechanic between players. I guess I could do this by having an object that looks at the item being pulled, but I was thinking there would be a way of just shooting a raycast at a target object, rather than using a bit of geometry to look at it.