playMaker

Author Topic: Rotate around game object  (Read 6104 times)

tim.holman

  • 1.2 Beta
  • Playmaker Newbie
  • *
  • Posts: 49
Rotate around game object
« on: September 06, 2011, 04:00:53 PM »
How do I force an object to rotate around another game object? In other words, how do I set one game object to be another game object's center of rotation (or pivot point)? For instance, take a golfing game. The player must rotate AROUND the ball in order to aim in a certain direction.

I've tried setting the pivot point object as the parent of the rotating object, but that didn't change anything. Any ideas as to how I can achieve this?

tobbeo

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 186
Re: Rotate around game object
« Reply #1 on: September 06, 2011, 05:12:29 PM »
To rotate one object around another, you do what you would do in a 3D program as well, you make it a child of that object. To make an object a child of another object, you just drag it on top of the other object (not in the prefab list, but in the game objects list). I often create an empty "gameobject", then drag another object onto it to in effect create a master pivot for the child object while still having a local pivot for the child.

markinjapan

  • Full Member
  • ***
  • Posts: 103
Re: Rotate around game object
« Reply #2 on: September 10, 2011, 01:18:40 PM »
Hello,

I'm trying to do a similar thing but I need multiple pivot points.

It's not possible to parent one mesh to multiple pivots (empty gameobjects), is it?

I've been trying to offset the mesh transform(Set Vector3 var, add offsets x, y, z, use the resulting Vector3 in Rotate) but I think theres a bug in Playmaker because it's not working.

I've also tried parenting multiple empty gameobjects (to use them as pivot points) to the mesh but that doesn't work either. Nothing happens when I Rotate using one of the child gameobjects as the GameObject Parameter in Rotate.

Anyone have a solution or is it just a matter of waiting for a bug fix?

Thanks



markinjapan

  • Full Member
  • ***
  • Posts: 103
Re: Rotate around game object
« Reply #3 on: September 13, 2011, 06:44:00 PM »
I finally worked out another way of doing this if anyone is interested.

I use Set parent to parent an empty GameObject to something, then if I want to change the pivot point, I unparent, Set a new Position and then reparent.

Easy to do with static objects but I guess if your render mesh is moving you will have to store the offsets needed to position your new pivot point(x1.5, y 3.5, etc ) and then use the render meshes origin to offset the pivot position.

Hope that helps someone.