botanist Posted November 15, 2010 Posted November 15, 2010 Hmm, tried a few things, but they all don't work correctly. I wanna create a function which can blow an element (ie a vehicle) towards a point with setElementVelocity. What I've did is probably too embarrassing to post, but the solution shouldn't be too hard. Anyone?
dzek (varez) Posted November 15, 2010 Posted November 15, 2010 i had somewhere a function to count angle between points, and i have a function to get an angle (comparing to Y axis) of element velocity - which you will have to "inverse" in some way. then you will be able to count it. let me search for them make a function from this, and return angle viewtopic.php?f=91&t=29586&p=324244&hilit=north#p324244 and a function to get angle of velocity: function getElementVelocityAngle(vehicle) if (isElement(vehicle)) then local vx,vy,vz = getElementVelocity(vehicle) local cosX2 = (math.deg(math.atan(vx/vy))+90) if (vy>0) then cosX2=cosX2+180 end cosX2 = 360-cosX2 cosX2 = cosX2+270 if (cosX2 > 360) then cosX2 = cosX2-360 end return cosX2 end end idk how to reverse it
botanist Posted November 15, 2010 Author Posted November 15, 2010 I can't use getElementVelocity. My element will be mostly standing still
DiSaMe Posted November 15, 2010 Posted November 15, 2010 function blowElement(element,x,y,z,speed) local ex,ey,ez = getElementPosition(element) x,y,z = x-ex,y-ey,z-ez local dist = math.sqrt(x*x+y*y+z*z) x = x*speed/dist y = y*speed/dist z = z*speed/dist setElementVelocity(element,x,y,z) end Didn't test, but it should work.
dzek (varez) Posted November 15, 2010 Posted November 15, 2010 remi-x - this was for getting this, not setting.. Doomed - lol, this makes sense.. probably all that math makes my brain crazy and now i want to solve every problem with this o_O
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now