playMaker

Author Topic: [SOLVED] Pull Player Towards Object  (Read 1456 times)

essejmclean

  • Playmaker Newbie
  • *
  • Posts: 5
    • jessemclean.ca
[SOLVED] Pull Player Towards Object
« on: June 13, 2015, 06:58:10 PM »
Hi all;

I've been attempting to pull my player towards an object for a while now, but have been having no luck.

My player is a Rigidbody that I add force against to move with touch swipes and charges. I want to be able to launch the player in the general direction of a pad and have them be PULLED onto that pad if they enter into a Trigger.

Again, the issue that I'm having is that I can't seem to get the pulling bit working. I should add that I'm open to using different solutions, be it Physics or iTween methods. Ideally, I would like the player to end up in the centre of the pad.

Any help would be excellent. My scouring of the forums and web have turned up dry on help for this.

Thanks.
« Last Edit: June 13, 2015, 10:43:38 PM by essejmclean »

essejmclean

  • Playmaker Newbie
  • *
  • Posts: 5
    • jessemclean.ca
Re: Pull Player Towards Object
« Reply #1 on: June 13, 2015, 10:41:51 PM »
[SOLVED]

Looks as though I had solved this myself many hours ago, only I failed to recognize the trivial issue I was having.

The way I worked this out was by using iTween Move To. Here's my setup:

State 1: I set up a Trigger Event that sent an event 'enteredTrigger.' In State 1, I also had a Get Position for the position of the pad and set a Vector3 Add XYZ to set an offset (since the pads are cubes and position grabs the centre).

State 2: I set up a Set Is Kinematic, to set my Player's rigid body to kinematic.

State 3: iTween Move To. Game Object set to the Player and the Vector Position as the position I gathered and added to in State 1. I added the pad position as the Look At Vector for good measure. I set an event called 'disableTrigger' in Event Finish. In State 3, I also put a Set Is Kinematic and unchecked 'is kinematic' for my Player's Rigidbody.

State 4: This is my Exit and Loop, I named it 'Exit Trigger' and gave it a FINISHED transition. Looped it back into State 1.


NOTE: I set my RigidBody to Kinematic because iTween Move To does not interact with Rigidbodies that are not kinematic. Setting Kinematic makes the Rigidbody like any game object that doesn't have a Rigidbody.

Viola.

j
« Last Edit: June 13, 2015, 10:45:26 PM by essejmclean »