Archived

This topic is now archived and is closed to further replies.

freelook & movement math

This topic is 5936 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

i get stupid about a problem with my moving. normal moving works correct. what i mean is if you look a bit up an press forward you will "fly" with the given speed in this direction. but here is the problem. i do not want to fly, i just want to run around with a constant speed on the ground without flying up to the sky if i look up. (in other words i just need the simple movement of a 3dshooter :/ ) for the normal camera movement i just do : 1.viewVec-PositionVec 2.and add the result to the current view and position vector of my camera. but if you want real movement you can not do it like this. even if i would not modify the y positions of these two vectors (in listed point 2), there would be the problem that if you look up, the z and x distances are shrinked to a small amount. the result is the more you look up, the slower you get. (logical so far...) i found a solution, but i am not sure why it works ( i always love such damn things ). the y of the dummyVec i calculate is set to 0. the calculated z value will be the same negative. or in c: dummyVec.y = 0.0f; dummyVec.z = -dummyVec.z; vecNormalize( &dummyVec ); // normaizes vector if i now add the dummyVec to my view and position vectors of the camera it works fine... but all i do now about the normalization is that it just means to scale the whole vector to values between -1.0f and +1.0f. Or does it do anything else? so i think it just seems to work fine because there are only little differences ( of course between >0.0 and <1.0 ) that are little enough so that you do not recognize that the movement gets slower. but in fact this i would be able to recognize this differenc or not ( this "little" value is of course influenced by a camera speed that has an amout of 400 and the difference between 0.5 * 400 and 1.0 *400 should be seen ) warg too confusing. i just dont get it. why does everything works fine now? i need to understand it. plz help me guys i hate things i code but do nor really understand. wheres this damn trick with the normalization... warg

Share on other sites
The ''trick'' is this:
You take a vector in any direction. It has magnitude equal to your standard speed. You now set the vertical component of the vector to zero. The vector now points along the ground, but will probably have a smaller magnitude than before (this is where your ''going slow'' problem was). You now normalise the vector. Normalisation scales the vector so that the direction does not change but the magnitude becomes 1. In this case it would appear that your original standard speed was also equal to 1, so the normalisation process works straight off. If your standard speed had originally been 2, you would have to scale the resulting vector up (*2) to get the correct result.

Hope this makes sense - key point is that normalisation scales a vector so that its magnitude is exactly 1 unit, not somewhere between -1 and 1 as you stated (in fact magnitude must always be >= 0, try moving less than 0 meters from where you currently are!)

Enigma

Share on other sites
mmh that would make sense.. with -1.0f to 1.0f i meant the value of the x y and z values after i divided them through the magnitude, and if one of them was negative it would stay negative (because magnitude can just be positive as you already said) thx, i think that helped a bit to understand whats going on there

1. 1
2. 2
Rutin
19
3. 3
4. 4
khawk
15
5. 5
A4L
13

• 13
• 26
• 10
• 11
• 44
• Forum Statistics

• Total Topics
633743
• Total Posts
3013644
×