Snarkpit Articles


This tutorial will show you how to create a tire swing with physics and constraints, and give beginners a quick lesson in some physics.

Obviously, start by making the area you want your tree and tire swing.

Create a prop_static entity, and browse for the model in the prop_foliage folder. I use tree_deciduous_01a.mdl- make sure the area you want it in is big enough!



Now its time to create the visual part of the tire swing. Select the move_rope entity and create it on one of the branches. This will take some fooling around in the top and side views, but use the 3D view to position it exactly- the centre of the entity should be inside the branch for best looking results.



Name it swing_rope01, set its slack to 0, and set rope material to cable/rope. There are other optional properties you can set which we leave to you to sort out.

Now create a keyframe_rope entity below the move_rope, a bit above the ground. Make the distance from the move_rope to the keyframe_rope as long as you want the rope on your swing to be.



Name it swing_keyframe01 and press apply. Now go back into the properties of our move_rope. Set the Next KeyFrame property to swing_keyframe01 and press apply. When you do this you should see a green/red line in Hammer linking swing_rope01 and swing_keyframe01.

Now its time to create the tire. Create a prop_physics entity and select a tire as the world model (they can be found in the prop_vehicles/ directory). Move this in your 2D views so it is right below our keyframe. The middle of the keyframe should be along the top surface of the tire.



Go into the properties of this tire and name it swing_tire01. Now go back into the properties of our keyframe_rope and set the Parent to be swing_tire01- this will connect one end of the rope to the tire.

If we tested this now the tire would fall to the ground, as the rope doesn't really have a fixed length yet. Create a phys_lengthconstraint entity in the same place as the keyframe_rope and name it swing_constraint01. Set Entity 1 toswing_tire01 and press apply. Keep the lengthconstraint selected and zoom into it in your side view. You should see a little circle in the middle which is the entity origin. You want to drag that little circle up and into the middle of our move_rope entity. This will basically give the tire swing constraints so that it won?t stretch all over the place- the distance defined by the constraint is that between the entity itself and the white circle we just dragged.



Now create a player start and test your map! You may notice that it's not terribly realistic- the rope won't get twisted around the tree, for example- but there's nothing you can do about this.



Post ReplyView Topic
Discussion
[author]
Posted by cbk on Sat Jan 15th 2005 at 2:12am

Not so much, read the tutoral i wrote on it
0 starsPosted by RaPtoR on Fri Jan 14th 2005 at 9:13pm

Great tutorial, very easy too read, and good pictures. I've give you a 8 though, since this effect isn't very hard to make.

About that dynamic lightning, isn't it just to place a dynamic_light below the model and enter the model name as parent?
0 starsPosted by SVIN on Mon Jan 10th 2005 at 4:20pm

In css this is weird i tried this example map and when i play it the tire move when i shoot it but the rope is just a straight rope to 1 of the walls or somthing
[author]
Posted by cbk on Fri Jan 7th 2005 at 9:27pm

I'm actually writing a tutorial on how to use this with dynamic lighting. So, if you had a lamp hanging like the tire in this tutorial and is producing a dynamic light. The light would follow where the light prop points. I'll be submiting it today or tomorrow.
0 starsPosted by habboi on Fri Jan 7th 2005 at 8:16pm

Can you do this with other objects such as lights?

Nice tutorial!
[author]
Posted by cbk on Fri Jan 7th 2005 at 5:07pm

Well, i don't know why you don't have that model in your folder. Maybe i typed it wrong or something. Check again. And the tire may have something to do with the tire model you chose, i had this problem and i just had to choose a different tire.
0 starsPosted by Gli2duS on Fri Jan 7th 2005 at 7:59am

Can you tell my why I don`t have model of this tree in my root/prop_foliage folder? and why after compiling map and run it in HL I can`t see this tire? when I come closer to the rope it`s moving. seems like ghost of tire smiley I can touch it but I can`t see it.
0 starsPosted by Dred_furst on Wed Jan 5th 2005 at 5:44pm

Nice smiley
0 starsPosted by Orpheus on Tue Jan 4th 2005 at 10:44pm

Starts chanting " /me wants trig, /me wants trig"

/runs
0 starsPosted by Vash on Tue Jan 4th 2005 at 5:50pm

Why would it need to be information packed, parakeet? What, would you like him to f**king calculate the physics in Trigonometry? This tutorial is perfect for people trying to do this. Goodjob.
Post ReplyView Topic