gob::gob(const tcomp& newPos, const tcomp& newVel, gob *newParent) : pos(newPos), vel(newVel), parent(newParent), solid(classSolid), lastPosAng(pos.Ang()+ang3d(1,1,1)) { vel.Scale()= pt3d(0,0,0); UpdateWorldPos(); }
void Arrow::Tick(float deltaTime) { Super::Tick(deltaTime); UpdateWorldPos(); Vector3 shippos = mPlayer->GetPosition(); Vector3 checkpos = mCheckpointPos; Vector3 direction = checkpos - shippos; direction.Normalize(); if( direction.x == 1 && direction.y == 0 && direction.z == 0) { SetRotation(Quaternion::Identity); } else { Vector3 axis = Cross(Vector3::UnitX,direction); float angle = Math::Acos(Dot(Vector3::UnitX,direction)); axis.Normalize(); Quaternion rotation(axis, angle); SetRotation(rotation); } }
/* Make this gob "act" for one game iteration. "Acting" typically includes one or more of the following: o morphing the gob (changing its shape or class) o setting the gob's velocity o moving the gob o interacting with other gobs Act() returns: o NULL, if the gob is destroyed, o a ptr to a new gob, if the gob becomes a different object (as in the tank to helicopter transformation), or o the "this" ptr, otherwise */ gob* gob::Act() { vel.Scale()= pt3d(0,0,0); // for right now... -PAH pos += vel; UpdateWorldPos(); return this; }
void Arrow::BeginPlay() { UpdateWorldPos(); }