CurryKitten / CurryKitten-Sim

FPV quad simulator
67 stars 7 forks source link

Pivot point on quad is wrong #83

Closed CurryKitten closed 3 years ago

CurryKitten commented 3 years ago

I was watching AndyRC show me some of his LOS acro flying, and we picked up from this that the quad rotated around the wrong points. It looked like it was rolling over the front motors, and the yaw point also looked out.

I don't think I've looked at this for a year or more, so there could well be stuff I was aware of then that I am now... I can't remember I need to investigate and see. Basically, the idea would be to make sure the pivot point is in the centre of the 4 motors.

CurryKitten commented 3 years ago

This illustrates the problem a little better (hopefully) The local pivot point of the quad is forward and slightly right of the camera and also floating slightly above it. This is usually an issue when a container is created for the components in a model (in this case the quad) where the parent object is set to a different transform position to the children.

The children's transformation becomes local to the container and so 0,0,0 would be in the same pivot point. The answer here is to manipulate the child positions until we can match up the centre of the frame with the pivot. This is easy when there's a single point, but does become more problematic with the many child components we have with the quad. Everything seems to line up nicely with it's own local pivot point except the base part of the frame which seems way off - so I'll look at this first.

Screenshot 2021-02-20 at 11 40 51

Screenshot 2021-02-20 at 11 41 18

CurryKitten commented 3 years ago

All fixed - albeit kind of painful, as the quad was perhaps the first object I had in the sim, and as such it's weirdly structured so 20-odd bodies all are children of the main container and so all needed individually changing. Happily, I was at least able to correct the base plate, look at the differences I needed to make in the x/y/z transformations and apply that difference to all the other bodies. Then I needed to correct the colliders in the same way, then the cameras, and the offsets for the exterior/interior camera in the code. This knocked out the start position on the Y slight as well, so that had to be fixed.

Annoyingly, although the quad object is a prefab, I'd managed to somehow use 3 different instances of it in the main sim, the game and the online version which I had to reapply all the changes on as well as a few extras for the trail objects in online.

However, I have tested it out and I can see that the rotation pivot point is dead centre... hooray.