Forum

Darkplaces setattachment in First Person?

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Darkplaces setattachment in First Person?

Postby Mexicouger » Sun Jul 29, 2012 9:53 am

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?
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Re: Darkplaces setattachment in First Person?

Postby Spike » Sun Jul 29, 2012 10:52 am

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.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Darkplaces setattachment in First Person?

Postby Seven » Sun Jul 29, 2012 1:06 pm

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:
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
Seven
 
Posts: 301
Joined: Sat Oct 06, 2007 8:49 pm
Location: Germany


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest