I'm trying to scale entities in CSQC according to player distance from them (player far -> bigger, player near -> smaller)
Code: Select all
void entitythink()
{
local float limit = 200;//without this, entities are scaled toooo big
self.scale = vlen(self.origin - player.origin) / limit;
self.nextthink = time +2;
self.think = entitythink;
}
I tried also Spike's workaround (a little modified to work in every direction), but with no luck
Code: Select all
void entitythink()
{
local float limit = 200;//without this, entities are scaled toooo big
local float minx,miny,minz,sizex,sizey,sizez,s;
self.scale = vlen(self.origin - player.origin) / limit;
s = self.scale / 2;
minx = self.mins_x * s; //determine the new model mins
miny = self.mins_y * s; //determine the new model mins
minz = self.mins_z * s; //determine the new model mins
sizex = self.size_x * s; //determine the new model size
sizey = self.size_y * s; //determine the new model size
sizez = self.size_z * s; //determine the new model size
self.solid = SOLID_BBOX;
setsize(self, [minx,miny,minz], [sizex-minx,sizey-miny,sizez-minz]); //and resize it.
self.nextthink = time +2;
self.think = entitythink;
}
Thanks for any input!!:)
PS: I used .think instead of .predraw just to control things step by step, in a temporal range of 2 seconds, which is easier to debug