Parenting Tests

So here in this video you can see the balls being shot out. The blue box is the position on the server, yellow box is the position on the client.

The player picks them up like this

	public override void StartTouch( Entity other )
		if ( IsClient ) return;
		if ( other.IsWorld ) return;
		if ( Parent != null ) return;

		if ( other is Player player )
			SetParent( player, "hat", new Transform( Vector3.Right * 60 + Vector3.Random * 20, Rot ) );
			EnableAllCollisions = false;
			MoveType = MoveType.None;
			Transmit = TransmitType.Never;

Then in the player’s tick, we have this:

		if ( Input.Pressed( InputButton.Use ) && IsServer )
			foreach ( var ent in Entity.All.Where( x => x.Parent == this ) )
				if ( ent is Gun gun )
					gun.MoveType = MoveType.Physics;
					gun.Transmit = TransmitType.Always;
					gun.SetParent( null );

So just a test to make sure that parenting and unparenting works like you’d expect.

The ‘hat’ attachment is created in modeldoc. The cool thing about this is that when you move it in modeldoc and save, everything in the game will automatically move with it.

Bonus Content:


Damn them some tasty physics


If the playermodel’s female why they topless?

i see :jeans:

1 Like

Cool stuff as always. And he’s finally got some pants on too! :smile:

1 Like


Goodbye pants.

Are the pants bonemerged?

dynamic bone weights?


if ( pants == null )
	pants = new ModelEntity();
	pants.SetModel( "models/citizen/clothes/trousers_tracksuit.vmdl" );
	pants.FollowEntity( this, true );

very cool g

God damn it’s so nice to see C# code used for gmod-style shit


Time to recreate the dancing pants video, that would be tricky.
Anyways, I was wondering why we would see the clientside position flicker around the map randomly after they are picked up, does it have to do with them not being rendered?

EDIT: I’m editing to not clutter the thread, the song is the Giant Enemy Spider looped over and over. Video is an old nickelodeon ad for the pants episode of Jimmy Newtron


song name? that tune sounds familiar.

1 Like

The ball stops being transmitted when it’s picked up, which is what causes the client to stop rendering it and stop receiving position updates.

EDIT: They’re not moving around, it’s just the camera movement that’s making it look like they are.

1 Like

I’m guessing this is when it stops updating on client since this code was run ServerSide only (Returned nothing after checking if it was on client)

And then

When he throws them out.
Didn’t notice it in the code, thanks.

1 Like

Yep, you got it.

1 Like

I was not looking foward to S&Box but since this and the forum being made it just makes me happy


Very nice progress as always.