Darkplaces setattachment in First Person?

Discuss programming in the QuakeC language.
Post Reply
Mexicouger
Posts: 514
Joined: Sat May 01, 2010 10:12 pm
Contact:

Darkplaces setattachment in First Person?

Post by Mexicouger »

Is this not possible? I can't seem to use tags in first person. When I spawn an entity on a tag for MD3 in first person, it goes straight to world '0 0 0'.
Am I trying to do something not possible, or how do I do it?
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: Darkplaces setattachment in First Person?

Post by Spike »

the player is an entity just like any other, but its worth noting that its normally skipped over.
however, DP still needs to add it for mirrors+shadows+etc, so I've no idea how it could not be a valid target for tags.

does cl_movement 0 fix anything?

Either way, you're probably better off using the entity .viewentityforclient extension/field instead, as a way to directly attach entities to the view (for view bob and stuff too). Better off, that is, if making a second viewmodel really is your aim.
Seven
Posts: 301
Joined: Sat Oct 06, 2007 8:49 pm
Location: Germany

Re: Darkplaces setattachment in First Person?

Post by Seven »

Hello Mexicouger,

I also once searched for a tutorial about how to use the "setattachment" correctly in DarkPlaces.
And I found a nice tutorial from Supa and jimmmy on this forum:
http://forums.inside3d.com/viewtopic.php?f=2&t=261
It is a must-read for you.

Then, just like Spike said, I was not happy with "setattachment" and went on to ".viewentityforclient".
This extension did the trick for me in the end.

What I wanted to do:
Stick a view-weapon model to the player in 1st person. Which is animated and follows the players movement fluently.
My task was to stick a almost transparent viewmodel when player uses the ring of shadows.
As you know, normaly the view-weapon is not shown/rendered during this in 1st person.
If this is any help for you, this is how I have done it:

Open client.qc and find CheckPowerups () and paste this to the end of:
if (self.invisible_finished)
{
...
}

Code: Select all

	newmis = spawn();
	newmis.movetype = MOVETYPE_NONE;
	newmis.solid = SOLID_NOT;
	newmis.viewmodelforclient = self;
	newmis.owner = self;
	newmis.alpha = 0.3;
	setmodel(newmis, self.weaponmodel);
	setsize(newmis, '0 0 0', '0 0 0');
	setorigin(newmis, '0 0 0');
	newmis.frame = self.weaponframe;	
	newmis.nextthink = time; 
	newmis.think = SUB_Remove;

Adjust the setorigin to any value you want for your specific needs.
This is a small clip that shows the above code in-game:
http://www.youtube.com/watch?v=Ki77zj7C58k&feature=plcp

If you need more examples of how to use ".viewmodelforclient", you will find the code how to add beautiful muzzleflashes in 1st person.
That is a perfect aplication for ".viewmodelforclient".

Also Nexuiz´s source is showing many different code with ".viewmodelforclient"and "setattachment" combined.

I hope this helps you a little bit.
Best wishes,
Seven
Post Reply