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 / Fix Aircraft to Carrier - fixobjecttoobject() - dilemma

Author
Message
Santiago3D
4
Years of Service
User Offline
Joined: 11th May 2020
Location: Argentina
Posted: 30th May 2020 21:23
Hello, I have a question, I don't know if it is technical or conceptual, rather it seems to be a dilemma.

I have my plane, which is flying super happy, and wants to land on the aircraft carrier.

The aircraft carrier is a ship, which moves, changes direction, heels and heads.

While the plane is flying, you abide by its physical flight rules.

When the plane hits the runway, I want it to couple the movements of the aircraft carrier, so the most optimal thing is to use Fixobjecttoobject, to link the aircraft to the aircraft carrier.


I currently have the plane, the carrier, and I have detected the point of contact of the plane with the carrier, so create a BASE_PIVOT object to link this pivot to the carrier, and to copy all its movements, while the plane is manually positioned on that pivot_base.


the problem I have, that when I apply fixobjecttoobject, the plane teleports.

If I use FIX to bind the base_pivot, or any other object, as soon as I link it, it teleports to a distant point.

I used Fixobjectpivot to reset the scales and everything to avoid scale problems.

Any ideas? How could I solve or address this dilemma?
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 30th May 2020 22:56
Personally, I would only use fix object to object once the aircraft comes to rest.

Prior to that, I would adjust the vectors of the aircraft depending on those of the ship.. You said you were applying manual physics to the aircraft so it makes sense to continue that way until you are no longer in control of it but allowing the ship to control it instead.

Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 30th May 2020 23:11
Quote: " I want it to couple the movements of the aircraft carrier"

i'll echo what scraggle said. i wouldn't (hard) fix the plane to carrier but add the carrier's movement to the plane's when its on the runway, instead.

otherwise, if you still want to use FixObjectToObject, please show a short code example because i get zero "teleport" using the command (and i see no reason to use FixObjectPivot alongside it).
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 31st May 2020 00:05
Fix object to object uses the co-ordinate space of the object you are fixing to. So you have to imagine if your fixing the object when the parent is at 0,0,0
So if you do something like


You might have to do some extra code to accommodate rotation
Santiago3D
4
Years of Service
User Offline
Joined: 11th May 2020
Location: Argentina
Posted: 31st May 2020 00:35
thanks for the answerrs, i will process all the data.

i think you have right about not parent until full stop.

i need to focus more in this topic.

thanks!
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 31st May 2020 00:56
a bit of math would be needed not sure if blinks code will work as haven't tested
but I use attach object extensively in https://www.youtube.com/watch?v=lvNd5CRPzzk&t=12s
and you need to calculate the position the plane would be in relation to both its world and local coordinates

steps
position
fixobject
move carrier
unfix object
fix position

its not the easiest of approaches that's why people are advising against it but in my video there wasn't
really a better method

do you know the offsets the plane would be in relation to the carrier because once you know that you can
calculate its difference to the current position

fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Santiago3D
4
Years of Service
User Offline
Joined: 11th May 2020
Location: Argentina
Posted: 31st May 2020 19:33
i am failing trying to get the position... because.

when i attach a object to carrier, the object teletransport.

so i need to calculate the local position of a not parent object manually, but my carrier is rotated and moved, in all axis, so, is very manual work.

will be more easy, if when i atach a object, the object attach where they are, and don't change your position.

you keep the global position, but only change local position.

i will work on that now.
Santiago3D
4
Years of Service
User Offline
Joined: 11th May 2020
Location: Argentina
Posted: 31st May 2020 20:10
this will more easy if there is the option to


place a child object over global position xyz, and global rotation.

and get the local position of that object.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 31st May 2020 23:00
Assuming the carrier only rotates along the Y axis (You can modify the code if the other rotations change)
What i have done is attached a center object to the carrier and used that as the object to attach to.
When attaching i rotate the center object at the reverse angle of the carrier and then attach the plane (Using the co-ordinate space of the ship)

Note: The plane doesn't have to be over the ship to attach. It can be anywhere

Santiago3D
4
Years of Service
User Offline
Joined: 11th May 2020
Location: Argentina
Posted: 31st May 2020 23:33
Excelent example code!!!! thanks Blink!!!!

is very nice example!!, you must put in help codes of agk!!!!!


my carriers turn in all axis, the roll a lot, but i go to use your code and try to add all axis!!!, thanks man!!!!
Santiago3D
4
Years of Service
User Offline
Joined: 11th May 2020
Location: Argentina
Posted: 1st Jun 2020 03:10
ok, this help me a lot!

now i can fix a object with global position, to a carrier, without teletransportation.


with that, i can know where my aircraft make contact with carrier.

next, when i move the ships, the carrier, i just relocate the airplane to the last position befor move the ship.

This is working right now!, so thanks!!!


i just changing the code, to avoid the creation of a new entity each time i attach sometiingh.

all this work only when the carrier no roll and turn, its time to find the way to do this with all axis rotation.


im testing, so you can see streaming in twitch.

https://www.twitch.tv/indiesoft/
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 1st Jun 2020 03:20
Line 103: is what aligns the rotation of the objects
RotateObjectLocalY(center, -GetObjectAngleY(ship))

I know you can get into trouble with orientation and 3D angles but my first try would be to add compensation for the X and Z rotations as well.
So try something like
RotateObjectLocalX(center, -GetObjectAngleX(ship))
RotateObjectLocalY(center, -GetObjectAngleY(ship))
RotateObjectLocalZ(center, -GetObjectAngleZ(ship))



Santiago3D
4
Years of Service
User Offline
Joined: 11th May 2020
Location: Argentina
Posted: 1st Jun 2020 04:34
Yes, its work, i make 2 functions.

this is with your code, and works perfect.
Attach a entity to another, withouth teletransportateion
but create the center objects.





now i working in a second function.
but dosent work when the ship turns

blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 1st Jun 2020 04:45
Could you provide a screen shot of the difference please?

Adding the box (or you could use a plane to minimize the polys) is absolutely zero overhead for the 3D system.
I would attach the box/plane when you load/initialize the carrier. In fact i think adding/removing it all the time is probably more overhead.
Santiago3D
4
Years of Service
User Offline
Joined: 11th May 2020
Location: Argentina
Posted: 1st Jun 2020 05:18
i think this is working very fine.

i have my brain "frito" friet? burn?

i thing, your code is very good, i just i need look more to understand the logic... with my brain fresh tomorow.

this is your code, with 3d rotation, works very perfectly.



Santiago3D
4
Years of Service
User Offline
Joined: 11th May 2020
Location: Argentina
Posted: 1st Jun 2020 05:20
when realease, change the angle, but i need to check a little, must be some small fix.

haliop_New
User Banned
Posted: 3rd Jun 2020 17:22
Can you please upload a picture or a video
Of the airplane landing on the ship.
Please please please.
I must see what you did i am very intrigued.
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 4th Jun 2020 14:13 Edited at: 4th Jun 2020 14:14
Quote: "Can you please upload a picture or a video
Of the airplane landing on the ship.
Please please please.
I must see what you did i am very intrigued."

Me too.

I probably would have given up on it and just make a success (automated landing) or fail (crash) depending on the plane's approach relative to the ship's deck having the outcome take place once contact was made.

In other words, a cut scene landing since that would be a stopping point (or break) in the mission. (when all else fails, work around it)

Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1

Login to post a reply

Server time is: 2024-11-22 05:20:31
Your offset time is: 2024-11-22 05:20:31