TwicH Posted June 16, 2016 Share Posted June 16, 2016 Hello guys, I'm just starting to learn to script and I've been stuck on this issue for a while now local x,y,z = getElementPosition (localPlayer) local zombie = createPed (20,x+math.random(-4,4),y+math.random(-4,4),z) function follow() x,y,z = getElementPosition (localPlayer) zpx,zpy,zpz = getElementPosition (zombie) local a = zpx - x local b = y - zpy local c = a*a + b*b local sinlaw = 90/math.sin(b) local zangel = math.sin(a)*sinlaw setPedCameraRotation (zombie,zangel) setPedControlState(zombie, "forwards", true) end setTimer ( follow, 500, 0) the code made sense the first time that I wrote it and since then I've just messed with a few variables without really thinking hoping that it would bring me an easy solution. also please don't ask me why I did the math the way I did, I'm very bad at it and that's what I came up with. Link to comment
Tomas Posted June 16, 2016 Share Posted June 16, 2016 Take a look at this function: https://github.com/nokizorque/GTI-sourc ... t.slua#L75 There you have all the math you have to do. Link to comment
TwicH Posted June 16, 2016 Author Share Posted June 16, 2016 Take a look at this function: https://github.com/nokizorque/GTI-sourc ... t.slua#L75There you have all the math you have to do. thanks Link to comment
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