OZONE Asylum
Forums
Multimedia/Animation
Vector Math/Moving Animations
This page's ID:
11426
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
ok, I got a pretty well working one now, only, if I reassign a new target in mid flight, it sometimes happens that it keeps on deaccelerating right of the screen, and never comes back. Somehow I can't find a way to fix it. here's my code so for [code] procedure TBasicObject.adjustDeltaVToTarget(); var targetPosConnection: TGLCoordinates; var distanceToTarget: single; var ticksToTarget,ticksToBrake: single; var newVector: TVector4f; var angle: single; var oldDeltaVLength: Single; begin if self.fpos.Equals(self.fTarget.AsVector) then begin self.deltaV.X := 0; self.deltaV.y := 0; self.deltaV.z := 0; end else begin targetPosConnection := TGLCoordinates.Create(nil); targetPosConnection.X := self.fTarget.X - self.fpos.X; targetPosConnection.y := self.fTarget.y - self.fpos.y; targetPosConnection.z := self.fTarget.z - self.fpos.z; distanceToTarget := targetPosConnection.VectorLength; if Self.deltaV.VectorLength = 0 then ticksToTarget := Infinity else begin ticksToTarget := (distanceToTarget / self.deltaV.VectorLength) end; ticksToBrake := (self.deltaV.VectorLength / self.maxDeltaVDelta); if (ticksToBrake >= ticksToTarget) then //this is the one that seems to go wrong when the glowbee keeps on 'deaccelerating' till all eternity... begin if distanceToTarget < self.maxDeltaVDelta then begin self.deltaV.Initialize(targetPosConnection.AsVector) end else begin angle := VectorAngleCosine(targetPosConnection.AsAffineVector,deltaV.AsAffineVector); oldDeltaVLength := self.deltaV.VectorLength; self.deltaV.AddScaledVector(-1 * Self.maxDeltaVDelta / targetPosConnection.VectorLength,targetPosConnection.AsVector); if self.deltaV.VectorLength > self.maxDeltaV then self.deltaV.AddScaledVector(-1,targetPosConnection.AsVector) end; end; end else begin targetPosConnection.Scale(Self.maxDeltaVDelta / targetPosConnection.VectorLength); self.deltaV.AddScaledVector(1,targetPosConnection.AsVector); if self.deltaV.VectorLength > self.maxDeltaV then self.deltaV.AddScaledVector(-1,targetPosConnection.AsVector); end; targetPosConnection.Free; end; end; [/code] Thank you for your replies, Tyberius Prime
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »