Gamestudio Links
Zorro Links
Newest Posts
Parent/child object
by VoroneTZ. 09/22/26 05:52
Zorro tutorial ideas?
by AndrewAMD. 09/21/26 14:50
Trades during a running bar
by Martin_HH. 09/21/26 12:03
Capital slider is not saving in Z12
by frutza. 09/17/26 13:36
Avoiding pop-up training parameter results
by Martin_HH. 09/16/26 21:31
What are you working on?
by rayp. 09/16/26 20:20
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
2 registered members (VoroneTZ, 1 invisible), 1,329 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
lopezsergio07, mistery, lokkalyansamiti, rahulbuilds, speedx
19237 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Parent/child object #489619
09/07/26 07:00
09/07/26 07:00
Joined: Oct 2003
Posts: 829
22�21'24"N 114�07'30...
Frederick_Lim Offline OP
User
Frederick_Lim  Offline OP
User

Joined: Oct 2003
Posts: 829
22�21'24"N 114�07'30...
Can't GameStudio add one object to another? For example, can I add object B to A, so that when I move/rotate object A, object B will move/rotate with it?

Re: Parent/child object [Re: Frederick_Lim] #489632
09/11/26 06:21
09/11/26 06:21
Joined: May 2009
Posts: 5,378
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,378
Caucasus
Nope, you'll have to move/rotate it by yourself.

In action function of ENTITY a, you could create ENTITY b as it's parent.
Then in while loop at the very end (after moving ENTITY a) you could check, if ENTITY b exists, and if it does, then move/rotate it with ENTITY a.

Code
action move_test()
{
	my.parent = ent_create(CUBE_MDL, my.x, NULL);

	while(my)
	{
		// move my
		
		if(my.parent)
		{
			vec_set(my.parent.x, my.x);
			vec_set(my.parent.pan, my.pan);
		}
		wait(1);
	}
}


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Parent/child object [Re: Frederick_Lim] #489654
1 hour ago
1 hour ago
Joined: Jun 2008
Posts: 60
Caucasus
VoroneTZ Online
Junior Member
VoroneTZ  Online
Junior Member

Joined: Jun 2008
Posts: 60
Caucasus
You can also use bones to attach objects to specific parts of the model.

Code
action attach_gun_to_actor
{
    var anim_percent = 0;
    you = ent_create("gun.mdl", vector(0,0,0), NULL); // create gun entity without animation

    while(1)
    {
        anim_percent += time_step;
        ent_animate(me, "walk", anim_percent, ANM_CYCLE);

        //attach gun to "RightHand" bone
        vec_for_bone(your.x, my, "RightHand"); // move gun entity
        ang_for_bone(your.pan, my, "RightHand"); // rotate entity

        wait(1);
    }
}


Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1