Spawn an entity during runtime?

FictiousWill

Newbie
Joined
Jul 22, 2003
Messages
2,658
Reaction score
1
I can find the proper coordinates in front of the player with a traceline, and I would like to spawn an instance of an entity, specifically a phys_constraint, during runtime. Anybody know what I have to call to accomplish this?
 
Ok I figured out how to spawn entities, but I can't get the phys_constraint to accept the entities it should hold together.

Code:
Welder = CreateEntityByName("phys_constraint");
Welder->KeyValue( "Entity 1", junkobject1->GetName()   );
Welder->KeyValue( "Entity 2", junkobject2->GetName()   );
Welder->SetAbsOrigin( tr.endpos + Vector( 0, 0, 0 ) );
Welder->Spawn();

junkobject2->GetName() is correct, I'm pretty sure that's returning the right name. I think I have the wrong keyvalue strings, but that's what was in Hammer.
 
Back
Top