required for both codes:
Code:
entity* ent1;
entity* ent2;
first code:
Code:
function attach_to_vertex(e1, e2, attachvertex)
{
var attach;
var attach_pos;
var roll_pos;
ent1 = e1;
ent2 = e2;
vec_for_vertex(attach,ent2,attachvertex);
vec_set(ent1.x,attach.x);
}
Attach_To_Vertex (entity1, entity2, attachvertex);
Used to attach entity2 to a vertex on entity1
entity1: the entity which will be attached to the first entity.
entity2: the entity which will be "holding" the attached entity.
attachvertex: the vertex of entity2 to attach entity1 to
Code:
function pan_to_vertex(e1, e2, facevertex)
{
var attach;
var attach_pos;
var roll_pos;
ent1 = e1;
ent2 = e2;
vec_for_vertex(attach_pos.x,ent2,facevertex); //vertice between thumb and pointer finger
vec_set(attach.x,ent1.x);
vec_diff(attach,attach_pos,attach);
vec_to_angle(roll_pos.pan,attach);
vec_set(my.pan,roll_pos.pan);
}
Pan_To_Vertex(entity1, entity2, facevertex);
used to make entity1 face a vertex on entity2, use with attach_to_vertex for things such as swords, hammers, etc
entity1: the entity which will face the vertex of entity2
entity2: the second entity, which uses a vertex to attach entity1
facevertex: the vertex of entity2 which entity1 will face
these can both be used to v-attach (using an vertex on one entity to attach another another entity to that vertex) like this:
Code:
action sword_model
{
while (me)
{
attach_to_vertex (me, you, 112); //attach the entity to the "hand" vertex
pan_to_vertex (me, you, 113); //make the entity "face" the second vertex
wait(1);
}
}