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.

Newcomers AppGameKit Corner / newobj=CloneObject(sourceobj) doesn't copy objects that were linked to the sourceobj using FixObjectToObject(sourceobj, targetobj) ?

Author
Message
Rick Nasher
6
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 5th Oct 2017 17:16 Edited at: 5th Oct 2017 18:27
Hi guys,

Still making good progress with my 'Universal 1st/3rd person (non physics) procedural framework'(open source), but...



First I was trying to create a bullet object, composed out of a capsule for the tip and a cylinder for the shell.
Then using FixObjectToObject I could then move these around as if it was one object.
I meant to use this multiple times using CloneObject, for the player would need to be able to shoot multiple bullets.

I was under the impression FixObjectToObject would create child objects linked to the parent object.


However I came across a couple of unpleasant surprises:
1) CloneObject() apparently *doesn't* copy objects that were linked using FixObjectToObject() .
Question: Is there a command that does do this?

2) The original orientation of a cylinder is vertical, so in order to shoot I had to rotate this object, but doing so doesn't change the original x, y, z angles permanently, so it messes up the shooting routing that was initially using spheres, which worked pretty well at first. Now I have to adjust the control routines, from moving into Z direction into Y direction?
Question: This doesn' t make sense as a solution. Is there a way to change the orientation of an manually(procedurally) created object permanently?

Any help is appreciated.
Rick Nasher
6
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 5th Oct 2017 17:44 Edited at: 5th Oct 2017 18:03
forgot to post code:



Which also nicely points out a discrepancy in syntax continuity between the commands CreateObjectCapsule and CreateObjectCylinder: diameter and height are used in a different order. Why not use the same parameter order across commands?

nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 19th Oct 2017 21:27
Hi Rick,
Quote: "
1) CloneObject() apparently *doesn't* copy objects that were linked using FixObjectToObject() .
Question: Is there a command that does do this?
"


No - and probably never should with manually fixed objects
The usual idea is that animated / boned / multi child objects would have a default rest "rig" which is fairly easy to instantiate from a simple create() function, which clones/instances and "rigs" whatever parts are needed.
This way you start of with a generic "thing" maybe in your case without a gun or without a hat.. etc. which you then customise after doing the generic create() function.
It may seem a pain to add all the bits and maybe setup pivots and other things, but you only need to do it once and suddenly it's really flexible.

Cloning object collections should have worked on objects loaded with LoadObjectWithChildren(), but I think that's still broken.
I did a lot of work with this sort of thing on this project so I've probably been through a lot of things you are experiencing!

Quote: "2) The original orientation of a cylinder is vertical, so in order to shoot I had to rotate this object, but doing so doesn't change the original x, y, z angles permanently, so it messes up the shooting routing that was initially using spheres, which worked pretty well at first. Now I have to adjust the control routines, from moving into Z direction into Y direction?
Question: This doesn' t make sense as a solution. Is there a way to change the orientation of an manually(procedurally) created object permanently?
"


As per the above method where you "rig" your objects to make a new collection all jointed together and what-not, you can also use this process to reset pivots and rotations.
If you want the cylinder to be rotated according to your gun position, but still have Z as your relative forward/backward direction, then the same "fixing" commands you use to assemble your character will do the job.

Something like: (untested)



You can extend this idea to reposition the pivot point as well.
Conjured Entertainment
AGK Developer
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 19th Oct 2017 23:33 Edited at: 19th Oct 2017 23:35
Quote: "2) The original orientation of a cylinder is vertical, so in order to shoot I had to rotate this object, but doing so doesn't change the original x, y, z angles permanently, so it messes up the shooting routing that was initially using spheres, which worked pretty well at first. Now I have to adjust the control routines, from moving into Z direction into Y direction?
Question: This doesn' t make sense as a solution. Is there a way to change the orientation of an manually(procedurally) created object permanently?"


Could you use a capsule instead of a cylinder???


Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
Rick Nasher
6
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 28th Oct 2017 10:32
Thanks for the replies guys. Sorry for the slow response, kinda mist this one.
Meanwhile I've indeed come across FixObjectPivot and that solved the orientation issue.

Guess my old Blitz3D ways need adjusting to the new situation . Bit of tunnel vision I guess..

Login to post a reply

Server time is: 2024-04-25 11:32:04
Your offset time is: 2024-04-25 11:32:04