darkplaces help with attach entities
Moderator: InsideQC Admins
7 posts
• Page 1 of 1
darkplaces help with attach entities
ive been reading through the darkplaces.qc trying to understand the quake3 attack entity script, and what ive gathered is that it allows seemless movement of one entity with another, such as say a weapon in the players hand (not first person tho) . Lets just say I wanted to make a hat or something, that you can have attached to players head. how do i set the attachment point for the hat? i think its tag_index but im not quite sure what it wants me to do with it
if someone could explain this a little for me i would much appreciate it. thanks!
-root
if someone could explain this a little for me i would much appreciate it. thanks!
-root
-

RooT - Posts: 40
- Joined: Wed Sep 07, 2005 1:28 am
To just attach an entity to an object, you need to call:
Of course, you'll need a tag to attach it to or the attacher entity will just attach to the center of the attachee.
Once an entity is attached to another, .tag_entity will return which entity it's attached to and .tag_index will return the index of the tag (tag_index of 2 would be the second tag, for instance). One last note, once an entity is attached to something it ignores collision, so you can't do things like hand held shields easily (You *can* do them, it's just harder).
[Edit: I managed to confuse even myself so I added an example to better explain what I was trying to say.]
- Code: Select all
setattachment(entity (the entity you want to attach), entity (the entity you want to attach it to), string (name of the tag to attach the entity to, ie 'tag_foo');
For example:
setattachment(foo, self, "tag_torso");
Of course, you'll need a tag to attach it to or the attacher entity will just attach to the center of the attachee.
Once an entity is attached to another, .tag_entity will return which entity it's attached to and .tag_index will return the index of the tag (tag_index of 2 would be the second tag, for instance). One last note, once an entity is attached to something it ignores collision, so you can't do things like hand held shields easily (You *can* do them, it's just harder).
[Edit: I managed to confuse even myself so I added an example to better explain what I was trying to say.]
aut viam inveniam aut faciam
-

Supa - Posts: 164
- Joined: Tue Oct 26, 2004 8:10 am
Supa wrote:One last note, once an entity is attached to something it ignores collision, so you can't do things like hand held shields easily (You *can* do them, it's just harder).
What's the best way to do attachments but still have collisions?
Use MOVETYPE_FOLLOW? Or attach the entity and have an invisible 'bounding box' using' MOVETYPE_FOLLOW or something similar?
Thanks.
- jimmmy
- Posts: 5
- Joined: Mon Nov 07, 2005 7:27 am
- Location: Australia
jimmmy wrote:What's the best way to do attachments but still have collisions?
Use MOVETYPE_FOLLOW? Or attach the entity and have an invisible 'bounding box' using' MOVETYPE_FOLLOW or something similar?
Both the MOVETYPE_FOLLOW (You'd actaully need MOVETYPE_NONE) and the bounding box (Again, MOVETYPE_NONE) method will work (The bounding box method will result in another entity per player though *and* the bounding box needs to be a reasonable duplicate of the shield model). Use DP_QC_GETTAGINFO to get the forward vectors of the shield tag and align the entity to match. Note that you're going to need to update the position and angles of the 'shield' every frame.
Note that if you use this method you will need to modify how your weaponset works or you'll get things hitting the bounding box of the shield when they shouldn't. (Much like firing a little over a grunts head and still hitting the grunt) For traceline weapons you just need to use MOVE_HITMODEL when you call traceline, please check dpextensions.qc for details on this. For projectiles you'll need to trace out from the front of the projectile a little each frame, again using MOVE_HITMODEL. I haven't actually tried using this with projectiles though, so I could be wrong.
'Hope this helps and let me know how it works, okay? =)
aut viam inveniam aut faciam
-

Supa - Posts: 164
- Joined: Tue Oct 26, 2004 8:10 am
Thanks for that help, however I don't seem to have my implementation quite right and aren't sure exactly what I'm doing wrong. I'm not familiar enough with quake c.
I'm using noctrun's md3 example code (http://mitglied.lycos.de/noctrun/q1md3/ ) as a base and fiddling around with md3 models using that (I'm experimenting before I waste any of my art orientated friend's time), my plan was to remove its usage of attach so that each body section can handle collisions with traces via MOVE_HITMODEL for simple location damage type stuff.
So far this is what I have:
UpdatePeopleModels is temporary while I get the basic code working, afterwards I'll do something more efficient. I'm just testing it out with the ranger replacement for the grunt / soldier.
I call AttachBodyParts from the setup function (setq3model in noctrun's code) and UpdatePeopleModels every frame like you said.
So I've commented out the setattachment bits of code and replaced them with AttachBodyParts (which doesn't do the head yet). But it doesn't seem to be working and my attempts at trying other methods and figuring out why have been rather unsuccessful.
Thanks for your help so far and any you can give me with this next bit.
I'm using noctrun's md3 example code (http://mitglied.lycos.de/noctrun/q1md3/ ) as a base and fiddling around with md3 models using that (I'm experimenting before I waste any of my art orientated friend's time), my plan was to remove its usage of attach so that each body section can handle collisions with traces via MOVE_HITMODEL for simple location damage type stuff.
So far this is what I have:
- Code: Select all
void(entity body) AttachBodyParts =
{
local float torsoTagIndex;
torsoTagIndex = gettagindex(body, "tag_torso");
gettaginfo(body, torsoTagIndex);
setorigin (body.torso, v_forward);
body.torso.angles = v_forward;
}
void() UpdatePeopleModels =
{
local entity people;
people = find(world, classname, "monster_army");
while (people)
{
AttachBodyParts(people);
people = find(people, classname, "monster_army");
// loop to next monster in sequence (the start parameter is now person)
}
}
UpdatePeopleModels is temporary while I get the basic code working, afterwards I'll do something more efficient. I'm just testing it out with the ranger replacement for the grunt / soldier.
I call AttachBodyParts from the setup function (setq3model in noctrun's code) and UpdatePeopleModels every frame like you said.
- Code: Select all
void(entity person, string mdl_legs, string mdl_torso, string mdl_head) setq3model =
{
if (person == world)
{
return;
}
//don't add new torso/head while respawning in multiplayer
if (person.md3partsspawned == FALSE)
{
person.torso = spawn();
person.head = spawn();
person.md3partsspawned = TRUE;
}
setmodel(person, mdl_legs);
setmodel(person.torso, mdl_torso);
setmodel(person.head, mdl_head);
person.head.exteriormodeltoclient = person;
person.torso.exteriormodeltoclient = person;
AttachBodyParts(person);
// setattachment(person.torso, person, "tag_torso");
// setattachment(person.head, person.torso, "tag_head");
person.torso.think = md3_player_animate_torso;
person.torso.nextthink = time + 0.1;
};
So I've commented out the setattachment bits of code and replaced them with AttachBodyParts (which doesn't do the head yet). But it doesn't seem to be working and my attempts at trying other methods and figuring out why have been rather unsuccessful.
Thanks for your help so far and any you can give me with this next bit.
- jimmmy
- Posts: 5
- Joined: Mon Nov 07, 2005 7:27 am
- Location: Australia
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest