|
Post by epikhbk1 on Jun 16, 2015 0:49:52 GMT
In my project, I'm using a car as a character, and the car's orientation is the Skinmesh's orientation that it's attached to. My question is, how would I set a specific part of the Quaternion to follow?
This is my script:
void Main()
{
Quaternion SkinOrientation;
Vector3 SkinLocation;
iObjectOrientation(OBJ_22, SkinOrientation);
iObjectOrientationSet(OBJ_0, SkinOrientation);
}
////OBJ_22 = SkinMesh //// OBJ_0 = Car
So if I wanted the car to only follow the X, and Y orientation, and not Z, how would I exclude it from following Z?
|
|
|
Post by F1Andre on Jun 16, 2015 7:17:42 GMT
Firstly, do you want the skin mesh to follow the car's body. And why so you want to lock it in the Z axis. Once you give me more info, I would be able to help you more effectively.
--Andrรฉ
|
|
|
Post by Power Supersport on Jun 16, 2015 14:27:10 GMT
Probably this should work, but I don't guarantee it...
void Main()
{
Quaternion SkinOrientation;
Quaternion Transformed; float x,y;
Vector3 SkinLocation;
iObjectOrientation(OBJ_22,SkinOrientation);
iQuaternionToEulerAngles(SkinOrientation,x,y,0);
iQuaternionFromEulerAngles(Transformed,x,y,0,"xyz"); iObjectOrientationSet(OBJ_0,Transformed);
} Better tell us more about your problem...
|
|
|
Post by epikhbk1 on Jun 16, 2015 15:54:03 GMT
Better tell us more about your problem... Well, I'm working on a project, and I'm trying to make the gravity Similar to the "Sonic the Hedgehog" video game series, where he runs through loops, ramps, and such. I'm using a car as the Character body because instead of using a "G-Force" object for gravity, I'm using a "Force" object, and it's locally orientated to the car, and it's always pointing downward under the car so that when the character runs through the loops and such, the gravity is always directly below him, so he is sticking to the object that he is running on.
|
|
|
Post by Power Supersport on Jun 16, 2015 17:02:25 GMT
And you want your car to be unable to rotate on Z-axis, right?
|
|
|
Post by epikhbk1 on Jun 16, 2015 17:09:56 GMT
Well, I just played with it, and I noticed that it was X that I wanted it to be, but no, I'm trying to make it so that it is able to only rotate on the X axis.
|
|
|
Post by F1Andre on Jun 16, 2015 17:37:45 GMT
Your best approach here from what I can see would be would to monitor the orientation of the character and if the character moves even the slightest you apply a counter force to bring it back to the centre. Now this is done correctly, your won't notice the object moving in the axis that you don't want it to move in.
I will think of a few other ways.
|
|
|
Post by Power Supersport on Jun 16, 2015 17:41:06 GMT
Try jointing Rigidbody (block) to the car and hiding it's geometry... then play around with the rigidbody's damping settings and you may get what you want... Follow: Add Rigidbody, move it in the center of your car... Add joint, set it to "Fixed Fast", connect it to the car and rigidbody... Link the car as "Body A", and the rigidbody as "Body B"... Link the rigidbody to your Force... Now you can play around with the mass of the rigidbody, the damping etc... You may get the results that you want...
|
|
|
Post by epikhbk1 on Jun 16, 2015 19:24:04 GMT
I think I found a way to do it, but I'll take that into consideration too. Thanks for your help guys.
|
|
|
Post by indiedev on May 7, 2016 5:18:35 GMT
you can dampen an individual axis using iObjectDampingApply
|
|