You know, entities don't have one direction vector but rather 3 of them. They are forward, right and up, and the corresponding E2 functions are E:forward()/right()/up(). They return unit vectors in the world coordinate system that point in the appropriate direction at the time the function is run. For instance, the points you have marked out might be something like this:.Code:E:pos()+10*E:forward() and E:pos()-10*E:forward()
toWorld() is indeed quite useful as a shorthand for stuff you want to define locally, though. The way it works is thatCombining those two, for that rotation there you could for instance doCode:E:toWorld(vec(X,Y,Z)) = E:pos() + X*E:forward() + Y*E:right() + Z*E:up()
The 10 in V and the 100 in Force are fiddlable constants that can be useful for adjusting to stuff that's very large or whatever - multiplying the force by the mass of the entity helps make its effects consistent.Code:V=vec(10,0,0) Force=100*Ent:right()*Ent:mass() Ent:applyOffsetForce(Ent:toWorld(V),Force) Ent:applyOffsetForce(Ent:toWorld(-V),-Force)


LinkBack URL
About LinkBacks




Reply With Quote








Bookmarks