Well it Kind of does
Do you have a method to attach it to the surface so its aligned?
eg the first example is no good if walking up a hill and was only to give you the rotation for strafing
heres a scripted ver if you dont but it uses trace and footprints can hang over edges
Code: Select all
local float strafemag;
local vector rot, vel, footpos;
local rotator newrot;
local float FD;
local Vector X, Y, Z;
local float CheckFrame;
//new stuff
local actor HitActor;
local vector HitLocation, HitNormal, Endtrace;
local rotator spawnrot;
local vector vec;
// GetAxes(Rotator(Vector(Rotation)*Vect(1,1,0)), X, Y, Z);
// above eh? not needed
GetAxes(Rotation, X, Y, Z);
FD=0.7;
CheckFrame=0.5;
if(AnimFrame < CheckFrame) // left foot and right was mixed up
{ //remove height
footpos = Location - CollisionRadius*FD*Y - CollisionHeight*z;
// footpos = Location + CollisionRadius*FD*Y;
// Log("Left foot");
}
else //remove height
{ footpos = Location + CollisionRadius*FD*Y - CollisionHeight*z;
// footpos = Location - CollisionRadius*FD*Y;
// Log("Right foot");
}
vel=Normal(velocity); //direction
vel.z=0;
rot =Normal(Vector(rotation)); //direction
rot.z=0;
strafemag = rot dot vel; // the angle between the way im facing and travelling
// dot value cosine of the 2 directions
//*************************************
// broadcast strafemag for testing REMOVE
if (strafemag > 0.8 || strafemag < -0.8)
BroadcastMessage( " Im walking forwards or backwards"$strafemag, false, 'say' );
else
BroadcastMessage( " Im strafing sideways or forwards or backwards"$strafemag, false, 'say' );
//*************************************
if ( strafemag < -0.5) // always face forward
rot= Normal(rot + vel* -1); // split the diference
else
rot= Normal(rot + vel); // split the diference
newrot=rotator(rot);
//spawn the test class arr
// end trace
Endtrace=footpos + (maxstepheight+10) * Vect(0,0,-1);
HitActor = Trace(HitLocation, HitNormal, Endtrace, footpos, true);
if (HitActor!=None)
{
vec =(Vector(newrot) dot Hitnormal)*Hitnormal;
vec=vector(newrot)-vec; // align to surface
spawnrot=Rotator(vec);
Spawn(class 'arr',,, HitLocation,spawnrot);
}