Howdy Unitoids! Marvelous app! I am finally getting the syntax down.
My CharacterController collides with an object with a MeshCollider and RigidBody with FreezeTransforms checked as well as isKinematic. If it is tagged “MovingSurface” I want to implement the controller riding that object but still have local autonomy of movement. I am not sure if I should use Vector3 or Quaternion or some Matrix math here to get the local position on a tagged moving surface the controller entered on ( obtained from OnCharacterControllerHit)and multiply(?) it or add and divide by two with the CharacterController position and rotation.
An example would be stepping on a Merry-go-round and then rotating with it where you stepped on but now as you move the character forward he is also maintaining his relative move and rotation… I will be doing it on FixedUpdate as long as the tag matches “MovingSurface” so I can implement it anywhere via tags.
If you’re implementing something like stepping onto a merry-go-round, a moving platform or an elevator, generally the best approach is to parent the player to the object (and unparent them when they get off it) since they’ll be inheriting the motion of the object, but still be able to move around freely.
The issue with that approach is that if any scaling has taken place then as a child object the CC takes on that scale. That is why I was seeking the math to implement it for rotation and position while ignoring scale. Unless there is a way to stop the scale from propagating to child objects. I don’t want to have to do a inversion of values to get the child scale equal in size to the unparented CC. It seems like an unnecessary code block. I have my coffee now and am going to start trying to multiply Vector3 or Qhaternions to see if I can get the answer I seek which was in the title. Parenting is not an option I wish to take unless I want to start creating 100 different scaled objects outside Unity and import them instead of using one mesh and resizing it for variation inside Unity.
So…the question is…use Vector3 or Quaternions and I believe you would multiply them and then apply the matrix to the CC transforms. Or am I whistling Dixie off key here?
Edit:Just tried parenting for giggles and it throws an error that I cannot rparent to a prefab to avoid data corruption. So… Quaternions and cross product, transform.eulerAngles and position of each the CC and moving surface and multiply or dot… Off to wikipedia and back to here till I get it.