@theneko if you're ONLY doing heading (angle of rotation as if you're looking down at a 2D map) then you can do this without problems. but if you are doing 3 axis rotation, you're screwed unless you do some fancy thing like i described.

@theneko if you don't do something like this, you will always have issues if the player tries to point the target direction too directly upwards or downward, because the direction vector has no roll information -- you have to calculate the pitch+yaw+roll from just a direction, and there are going to be multiple equivalent solutions for that.

@theneko this took me like a solid week to get working correct :P i think you can probably just rip most of the code out of hunting anubis for it

@theneko BUT it progressively gets looser about returning roll to 0 the more the aircraft's nose is pointing towards the sky or ground. after a certain threshold (i can't remember what) it completely stops caring about the roll angle, letting players do loops or whatever without having to fight against the control system, and then returning to "reasonable" behavior and attempting to align with the horizon afterwards.

@theneko the way it works is that you give it a target vector and it attempts to pitch+yaw+roll the aircraft to point in the correct direction, and prefers to return the roll angle to 0 once the yaw angle towards the target direction is correct.

@theneko also i'll warn you that the mouse control thing gets very fussy if you want players to be able to adjust pitch freely, like doing loops and stuff. you will need a more sophisticated model. the one i put in hunting anubis becomes progressively more "free" on attempting to stabilize the roll axis as the aircraft's noise points away from the horizon.

@theneko so you're trying to manipulate or look at a rotation angle (the roll) which doesn't exist.

@theneko ok so you're just using some quaternion or pitch+yaw+roll to hold what's actually direction vector. in that case the code doesn't make any sense. because there is no meaning to 1 of the 3 components of the pitch+yaw+roll.

@theneko anubis before or after i fixed it? :P it had gimbal lock problems before i rewrote it

@theneko a direction has no rotation, it's just a direction

@theneko then i don't understand how you are calculating 'finaldesiredrotation'

@theneko which is it that you want? you want the aircraft to adjust pitch/yaw/roll to point in a specified direction, or you want to specify a number of degrees for the aircraft to match its roll amount to?

@theneko ok yeah this is not what i thought you were describing. i thought you were asking how to roll an aircraft so that it turns towards a target (another aircraft or a position in space) not how to match a target amount of roll.

@theneko how are you calculating 'finaldesiredrotation'?

@theneko this isn't like what i described at all. this code can't work.

@theneko actually i'm not really sure what's going on here. i don't understand what 'rollAngle' is supposed to be.

@theneko i don't understand what the 'deltarotation' variable is for

@theneko so something else must be going wrong, or something extra is happening that you aren't aware of, or something

@theneko well it must be something else, since this is the method i use to do what you're trying to do.

float towards = normalize_rot(target_angle - current_angle);
if (towards < 0.0) turn_left_a_little;
else turn_right_a_little;

Show older
Merveilles

Revel in the marvels of the universe. We are a collective of forward-thinking individuals who strive to better ourselves and our surroundings through constant creation. We express ourselves through music, art, games, and writing. We also put great value in play. A warm welcome to any like-minded people who feel these ideals resonate with them.