Hi guys,
First post, so hello
Your forums have been really helpful so far, I’m hoping they can save me from madness and help me here too.
Basically I have a flat object, call it “chassis” and I want to attach another object, lets call it “hoverPad” at a certain point.

- The hoverPad should be attached to the chassis at a point which is offset from the chassis centre by a fixed amount, thus appearing as one object.
- The rotation of the hoverPad should match that of the chassis so they appear to move as one object.
I have tried joints (fixed, hinged or configurable), however relying on the physics engine to keep it together does not produce reliable or stable results. My research tells me that it is best not to use the physics joints for such a dynamic situation as it can’t keep up without tweeking that would result in massive lag.
This has brought me to using scripting to move the object to where it should be each frame, coding this inside the function Update section of code. First, matching the rotation is easy enough:
public var gravPlating : Transform;
public var chassisObject : Transform;
function Update ()
{
var gravPlatingXRot : float = chassisObject.eulerAngles.x;
var gravPlatingYRot : float = chassisObject.eulerAngles.y;
var gravPlatingZRot : float = chassisObject.eulerAngles.z;
gravPlating.eulerAngles = new Vector3(gravPlatingXRot, gravPlatingYRot, gravPlatingZRot);
}
Now moving it’s position is a bit more tricky! I had this originally:
public var gravPlating : Transform;
public var chassisObject : Transform;
public var offsetX : float;
public var offsetY : float;
public var offsetZ : float;
function Update ()
{
var gravPlatingXPos : float = chassisObject.position.x + offsetX;
var gravPlatingYPos : float = chassisObject.position.y + offsetY;
var gravPlatingZPos : float = chassisObject.position.z + offsetZ;
var gravPlatingXRot : float = chassisObject.eulerAngles.x;
var gravPlatingYRot : float = chassisObject.eulerAngles.y;
var gravPlatingZRot : float = chassisObject.eulerAngles.z;
gravPlating.eulerAngles = new Vector3(gravPlatingXRot, gravPlatingYRot, gravPlatingZRot);
gravPlating.position = Vector3(gravPlatingXPos, gravPlatingYPos, gravPlatingZPos);
}
You can see the previous rotation code and now the added position code, this includes a user definable offset for each axis, this allows different hoverPads to be located in different positions using the same code. Those with a keen eye (or maybe it’s blatantly obvious) can see that this won’t produce the required behavior. Instead, it will move the hoverPad in relation to the centre of the chassis. Like so:
So I realise that I’m going to need to do a few more calculations to alter the position. I have an idea of a set of trigonometric calculations I could use, implementing them correctly is a bit harder though.
Before I pour out a ton algebra on how I think I could do this, I first thought I’d ask if there is a simpler way to move rotate one object with another, perhaps using built in unity magics? Or maybe I’m just going about this completely the wrong way…
Thanks in advance,
John.
PS: if you wondered how i plan to push up with the hoverPad, I was going to do a short raycast out of the top of it, then add force to the chassis where it collides.
