PDA

View Full Version : tilt effect?



enjoycrf
03-23-2011, 08:26 PM
hi
im making a barrel for my fps that responds to my bsp and my bullets
i made it move around based on bullets pushing it
just by getting the barrel move vector with subtracting barrel center from barrel bullet hit point
i also made it spin a variable bit by getting the dot product of bullet rebound vector and the original bullet vector
and that looks really cool but i cant stop there i dont know why
so now i want to add tilting of the barrel when i hit it above the center
so that is my question
how do i calculate the x and y axis rotation for tilt from the bullet direction vector
if i set the barrel z rotation to my camera z rotation kind of like a sprite then if i rotate it back on the y axis it works fine
but obviously i need the z rotation to stay put while i walk around the barrel
and make it tilt back when i shoot it
and hopefully not just tilt it back but per the bullet rebound vector
that if i hit it from the front on the side it would tilt to the oposite side and back a little
i hope this is not as hard to do as i think it is

enjoycrf
03-25-2011, 05:03 PM
i did my babies!!!
the key is entityWorldAngle
to tilt the object in the direction opposing the shot is just to simply set xy rotation to the xy bullet vector
then when you walk around the barrel shooting at it the barrel will always tilt back
then when the bullet spins the barrel it will want to tilt based on its forward vector
so you have to get the angle between the barrel forward vector and the world forward vector
then just rotate the bullet vector by that angle
and that will correct it to always tilt back again
this looks so nice and realistic

now i finally realize that i need to make globally available vars like

WorldForwardVector
WorldRightVector
EntityForwardVector
EntityRightVector

and so on...



vec3_t wtf2, rv;

wtf2[2] -= 90;
wtf2[2] -= entityWorldAngle;

VectorRotateQ3(aVec2, wtf2, rv);

c->angle[0] = rv[0] * 20;
c->angle[1] = rv[1] * 20;