Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] Set angle X local ??

Author
Message
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 31st Aug 2018 09:06 Edited at: 31st Aug 2018 09:22
Im really after a set object angle local command

So I have this code

which uses this function

but what it does is it keeps rotating locally the amount returned by ang# I was hoping by creating another object I could get the new angle and it would
only move when I did. not constantly rotate like It is now I may need to do some vector math any help greatly appreciated
fubar

The author of this post has marked a post as an answer.

Go to answer

Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 31st Aug 2018 09:35
I think you are over thinking this - you can just replace ALL that code with


SetObjectLookAt(turrets[towerNum].id,getObjectX(heliObj),getObjectY(heliObj),getObjectZ(heliObj),0)

That instantly sets the turret to point at the helicopter

Are you trying to limit the rate of turning of the turret??
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 31st Aug 2018 10:04
unfortunately I cant use that like that because the turrets are fixed to a base and I only want the objects local angley facing the helicopter
the other angles need to remain the same

Quote: "I think you are over thinking this"

That is often the case with me but i dont think so this time

fubar
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 31st Aug 2018 10:31 Edited at: 31st Aug 2018 10:34
Ahh I see!! (well, I think maybe I do?)

Ok so look at the helos position but with its y position set to be the same as the turret. This causes rotation only around the y axis.

SetObjectLookAt(turrets[towerNum].id,getObjectX(heliObj),getObjectY(turrets[towerNum].id),getObjectZ(heliObj),0)

Maybe try that...if not i iwll have a look a bit later on after work and im sure theres an easy way.
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 31st Aug 2018 10:47
This works half the time now the problem is the angle I get from the get2dangle is not right
quite right I know the model points north by default and when I set it up I use setobjectlookat same as below
and then rotateonljectlocalx so I figured below would work well its close must be a prob now with my get 2dAngle
or im passing the wrong values but I used that function before in 3d and it worked in night driver I used it to rotate
the cars toward centre of road


I shouldn't have to set ABS but that made it right for half of the screen
fubar
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 31st Aug 2018 10:57 Edited at: 31st Aug 2018 10:58
I noticed that your putting the x difference into the y value into Atan2 and the y difference into the x value.... not sure why?

Your also using X1# - x2# therfore working out the angle from the helo to the turret not the angle from the turret to the helo


I'm still not sure why your using your Get2dangle function as the look at function in agk just sorts the angles out for you and so you wouldnt need your function at all.
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 31st Aug 2018 11:37 Edited at: 31st Aug 2018 11:42
This post has been marked by the post author as the answer.
The turrets are set up like this

and sit attached to a planet object that rotates


This function for pointing the turrets is very close to what i wanted to achieve
but using x and z coordinates instead of x and y. it does point a bit towards the heli


the function it calls for any new comers


This thread shows it working theres a video at the 2 page down the bottom https://forum.thegamecreators.com/thread/222833

ps the missile routine already points where its supposed to just want the turrets to match
fubar
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 31st Aug 2018 11:53 Edited at: 31st Aug 2018 14:19
If the missile tracking works couldn't you just copy that?

Anyway - this is simple turret tracking without working out the angles - the bases rotate around y axis only where as the turrets fully face the flying object


Your angle function gives a positive angle when x<0 and y>0??? Thats a positive angle for an anticlockwise rotation? AppGameKit is the opposite coordinate system. You pass the x coords into the y value of Atan which is why its giving you the opposite angle direction.

I'm really not sure what your trying to do now so good luck with it.
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 1st Sep 2018 00:00 Edited at: 1st Sep 2018 00:26
Thanks that's a really good example I want to do what your base does

so i did SetObjectLookAt(turrets[towerNum].id,getObjectX(heliObj),0,getObjectZ(heliObj),0)

which points it in the air not rotate on y=axis like in your example I dont think i can do the same because the turrets all rotate around the centre of a planet

example pic the tirrets on that i just want to point at just above heli to the right shows a turret



but I did come across these on wiki I thought might be useful


fubar
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 1st Sep 2018 03:04
On second attempt it did work thanks @Bengismo to use that method I need a top facing model instead of a front facing model

thanks for your help
fubar

Login to post a reply

Server time is: 2024-04-26 06:37:43
Your offset time is: 2024-04-26 06:37:43