sticking entities to players
Moderator: InsideQC Admins
11 posts
• Page 1 of 1
sticking entities to players
Hey all. I was dabbling a bit in QuakeC trying to make an entity to stick to the player.
Its suppose to be a vehicle that sicks to you when you touch it (simulating you getting in the car) and then lets you drive off...
The sticking part works until your car touches a wall and then the car kind of falls off your player model.
Here's my code:
I tried to remedy this by using the self.solid = SOLID_NOT; line as you can see, but this just made the player drop the entity instantly.
Is there a quick fix for this?
Any help is appreciated.
Its suppose to be a vehicle that sicks to you when you touch it (simulating you getting in the car) and then lets you drive off...
The sticking part works until your car touches a wall and then the car kind of falls off your player model.
Here's my code:
- Code: Select all
void() car_touch;
void() item_vehi =
{
self.touch = car_touch;
setmodel(self, "models/car.mdl");
setsize (self, '0 0 0', '32 32 56');
StartItem ();
};
void() car_touch =
{
if (other.classname != "player") //monsters can't drive
return;
//self.solid = SOLID_NOT; //make the item not solid
self.origin = other.origin;
if ( (self.velocity == VEC_ORIGIN) )
self.avelocity = VEC_ORIGIN;
sv_friction = sv_friction * .5;
sv_stopspeed = sv_stopspeed * 4;
};
I tried to remedy this by using the self.solid = SOLID_NOT; line as you can see, but this just made the player drop the entity instantly.
Is there a quick fix for this?
Any help is appreciated.
- Boss429
- Posts: 39
- Joined: Sun Dec 03, 2006 7:29 pm
well off the top of my head, you can set the car's .think function and .nextthink = time + 0.05
and update the car's origin to the player's origin 20 times per sec.
of course you also must create some code to release ownership of the car after they get out...
and update the car's origin to the player's origin 20 times per sec.
- Code: Select all
void() drive_me_crazy =
{
if (self.movetarget)
{
setorigin(self, self.movetarget.origin);
self.angles = self.movetarget.v_angle;
self.v_angle = self.movetarget.v_angle;
self.fixangle = TRUE;
self.nextthink = time + 0.05;
}
};
void() car_touch =
{
if (other.classname != "player") //monsters can't drive
return;
self.movetarget = other;
self.think = drive_me_crazy;
self.nextthink = time + 0.05;
};
of course you also must create some code to release ownership of the car after they get out...
- r00k
- Posts: 1110
- Joined: Sat Nov 13, 2004 10:39 pm
-

Error - InsideQC Staff
- Posts: 865
- Joined: Fri Nov 05, 2004 5:15 am
- Location: VA, USA
Error, thanks for point that out. But how duth one use this movetype_follow?
Here's what I tried:
am I missing something?
Here's what I tried:
- Code: Select all
void() car_touch;
void() item_vehi =
{
self.touch = car_touch;
setmodel(self, "models/car.mdl");
setsize (self, '0 0 0', '32 32 56');
self.movetype = MOVETYPE_FOLLOW;
StartItem ();
};
void() car_touch =
{
if (other.classname != "player") //monsters can't drive
return;
//self.solid = SOLID_NOT; //make the item not solid
self.aiment = other;
sv_friction = sv_friction * .5;
sv_stopspeed = sv_stopspeed * 4;
};
am I missing something?
- Boss429
- Posts: 39
- Joined: Sun Dec 03, 2006 7:29 pm
esentually:
that is, put the following ent view_ofs units away from the followed origin based on the followed's angles.
you can rotate the followed ent around the owner by changing punchangle too.
or something like that.
note that movetype_follow can be a frame behind, depending on spawn sequence. it is not practically usable on player entities.
- Code: Select all
void() movetype_follow_think =
{
makevectors(self.aiment.angles);
self.origin = self.aiment.origin + v_forward*self.view_ofs_x + v_right*self.view_ofs_y + v_up*self.view_ofs_z;
self.angles = self.v_angle + self.aiment.angles;
};
that is, put the following ent view_ofs units away from the followed origin based on the followed's angles.
you can rotate the followed ent around the owner by changing punchangle too.
or something like that.
note that movetype_follow can be a frame behind, depending on spawn sequence. it is not practically usable on player entities.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
r00k: nexthink = time is essentially for this sort of thing, as it means it updates every frame. It won't get stuck in a loop if that's what you're worried about, it just means it updates every frame.
Of course depending on entity order the sticking entity may end up one frame behind, which is a problem I'm having in DiD2.
Any solutions? Other than md3 tagging...
Of course depending on entity order the sticking entity may end up one frame behind, which is a problem I'm having in DiD2.
Any solutions? Other than md3 tagging...
Apathy Now!
-

MauveBib - Posts: 634
- Joined: Thu Nov 04, 2004 1:22 am
Mauve: Well, instead of having each individual piece think independently, you can instead have the main core entity do the thinking, and it updates everything all at once (i.e. in its .think or in player post think). When it moves or turns etc, it updates its child pieces. The example below has a parts list as a linked list (instead of a .entity for each possible part):
Or use MOVETYPE_FOLLOW in DP or another supporting engine, which should presumably keep them fairly effectively attached (not sure how clean it is).
- Code: Select all
// position/angle has changed. Update all pieces following me
head = self.attachedPart;
while(head != world) {
head.origin = self.origin + v_forward * head.view_ofs_x + v_right * head.view_ofs.y + v_up * head.view_ofs.z;
// also do angles, etc
head = head.attachedPart;
}
Or use MOVETYPE_FOLLOW in DP or another supporting engine, which should presumably keep them fairly effectively attached (not sure how clean it is).
When my computer inevitably explodes and kills me, my cat inherits everything I own. He may be the only one capable of continuing my work.
- Wazat
- Posts: 771
- Joined: Fri Oct 15, 2004 9:50 pm
- Location: Middle 'o the desert, USA
11 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
