I'm trying to predict entity's position(vector) after certain amount of time..
I've tried something like this:
trigger:[CODE]self.PosPT = CurTime()+ 0.1
self.BPos = ent:GetPos()[/CODE]Think:[CODE]if CurTime() >= self.PosPT then
self.PosPted = ent:GetPos()+ (ent:GetPos()- self.BPos)* self.PosPmul
end[/CODE]This isint a copy paste, this is straight from my head while writting this thread.. So might not work if you try it, but you get the idea what i dried to do since it worked for me. The problem is i want it to always predict the position judging by its velocity, not by trigger. Where should i start?
--EDIT--
Yeah yeah, i know i made a mistake in the title..
You want to get the entity's position in the future assuming it's travelling in a straight line? You could do:
[lua]
self:GetPos()+self:GetVelocity()*secondsinfuture
[/lua]
If it's an entity that has prop physics you might have to do this instead:
[lua]
self:GetPos()+self:GetPhysicsObject():GetVelocity()*secondsinfuture
[/lua]
[QUOTE=MegaJohnny;23867949]You want to get the entity's position in the future assuming it's travelling in a straight line? You could do:
self:GetPos()+self:GetVelocity()*secondsinfuture
If it's an entity that has prop physics you might have to do this instead:
self:GetPos()+self:GetPhysicsObject():GetVelocity()*secondsinfuture
[/QUOTE]
I thought GetVelocity() returns a number :/ How didnt i think of that :/
Anyway.. Works perfectly, ty.
Sorry, you need to Log In to post a reply to this thread.