View previous topic :: View next topic |
Author |
Message |
Nash

Joined: 19 Oct 2007 Posts: 95 Location: Kuala Lumpur, Malaysia
|
Posted: Sat Oct 20, 2007 12:38 pm Post subject: [DP] Bumpy movement problem |
|
|
I'm new to QuakeC, so to teach myself the language, I decided to go for something simple first... like making a Doom 3-style cubemap flashlight (let's not get into the "flashlight sux" argument; the mod this is intended for will have nothing to do with Quake anyway).
But I notice that when the player moves up stairs, the flashlight bumps up and down really hard, like as if it's not keeping up with the player's movement.
Is there a way to interpolate the flashlight's position just like how the player's view is interpolated as he moves up and down?
Code: |
// flashlight code
// player flashlight state
.float flashlight_state;
.entity flashlight;
void() flashlight_think =
{
if (self.owner.health > 0)
{
//setorigin(self, self.owner.origin + (self.owner.view_ofs - '0 0 16'));
makevectors (self.owner.v_angle);
traceline (self.owner.origin, (self.owner.origin + (v_forward * 32)), FALSE, self);
setorigin(self, trace_endpos + (v_forward * -16) + (self.owner.view_ofs - '0 0 8'));
self.angles = self.owner.v_angle;
self.angles_x = self.angles_x * -1;
self.nextthink = time;
}
};
void() player_flashlight =
{
local entity newflashlight;
newflashlight = spawn();
newflashlight.pflags = PFLAGS_FULLDYNAMIC;
newflashlight.light_lev = 1024;
newflashlight.color = '2 2 2';
newflashlight.skin = 200;
newflashlight.owner = self;
self.flashlight = newflashlight;
newflashlight.think = flashlight_think;
newflashlight.nextthink = time;
};
void () player_flashlight_toggle =
{
if (self.flashlight_state == FALSE)
{
self.flashlight_state = TRUE;
player_flashlight();
}
else
{
self.flashlight_state = FALSE;
self.flashlight.think = SUB_Remove;
self.flashlight.nextthink = time;
}
};
|
My second problem is also related to the above; I notice corpses and gibs and stuff like that have very jerky movement when they are placed on lifts (it's easy to see if you kill the grunt in the first lift in E1M1). Is there any way to fix that, too?
Thanks. |
|
Back to top |
|
 |
FrikaC Site Admin

Joined: 08 Oct 2004 Posts: 947
|
Posted: Mon Oct 22, 2007 8:20 pm Post subject: |
|
|
Quote: | I'm new to QuakeC, so to teach myself the language, I decided to go for something simple first... like making a Doom 3-style cubemap flashlight. |
You need to re-evaluate what something simple is. |
|
Back to top |
|
 |
Chris
Joined: 05 Aug 2006 Posts: 78
|
Posted: Fri Nov 02, 2007 12:34 am Post subject: |
|
|
For keeping up with the player it may be because you have
self.nextthink = time;
which in actuality isn't the fastest possible run through that code.
Workarounds would be akin to you "attach light to entity out in front " simply make an entity, tag it to (player origin / nonexistant tag on player), offset it forward on the player, and give it the light effects you desire.
see: SetAttachment function in dpextensions.qc
Also possibly moving the light closer to player kind of changes the illusion. You could lower light_lev and set it to v_forward by 10 units. |
|
Back to top |
|
 |
Nash

Joined: 19 Oct 2007 Posts: 95 Location: Kuala Lumpur, Malaysia
|
Posted: Fri Nov 02, 2007 5:05 am Post subject: |
|
|
But I thought setattachment won't draw the attachment in first persion view if it's attached to the player? |
|
Back to top |
|
 |
ajay

Joined: 29 Oct 2004 Posts: 295 Location: Swindon, UK
|
Posted: Sat Nov 08, 2008 10:40 am Post subject: |
|
|
Nash; ok if I use this in my own mod?
cheers _________________ my site |
|
Back to top |
|
 |
skite2001

Joined: 17 Nov 2008 Posts: 17
|
Posted: Wed Jun 30, 2010 5:23 pm Post subject: |
|
|
is there a new "updated" code out there maybe?
if i use this code on my mod with darkplaces, the complete screen got brighter instead of only a "light-stripe" as seen on doom3 flashlight.
seems actually that "http://www.inside3d.com/qctut/qctut-8.shtml" looks better, if there is no fix for this |
|
Back to top |
|
 |
Spike
Joined: 05 Nov 2004 Posts: 944 Location: UK
|
Posted: Wed Jun 30, 2010 5:28 pm Post subject: |
|
|
the code above uses a cubemap for the light effect.
if you provide only the code and not the cubemap then you get a uniform light that shines in all directions and not just infront. _________________ What's a signature? |
|
Back to top |
|
 |
|