Rage through 32 single player levels and 6 deathmatch levels of sheer terror and fully immersive sound and lighting. Arm yourself against the cannibalistic Ogre, fiendish Vore and indestructible Schambler using lethal nails, fierce Thunderbolts and abominable Rocket and Grenade Launchers.

Post tutorial Report RSS Quake c - Velocity

Move and rotate quake entities with velocity. --

Posted by on - Intermediate Server Side Coding

Velocity is the rate of change of the position of an object, equivalent to a specification of its speed and direction of motion: En.wikipedia.org
The scalar absolute value (magnitude) of velocity is called "speed".

// defs.qc
.vector avelocity;
.vector velocity;
".velocity" defines one of the per-entity variables the quake engine works upon directly.
This is one of the most important concepts in the game, and it receives very little coverage in programming context. One of the easiest ways to move something in the game is to set velocity and movetype.

".avelocity" is just a scalar value that defines rotation speed (and sign for direction) about an axis - x, y, z, accordingly. ".avelocity" has no typical use as a standard vector.

When gibs and grenades flip around as they fly along, this is done by setting ".avelocity":

newmis.avelocity = '300 300 300'; // in W_FireGrenade


Using ".velocity" - code from "void () W_FireRocket" in weapons.qc:

// self is the rocket firing player, newmis is the missile entity

makevectors (self.v_angle); // put gun aim into 1 unit (normal) angles v_forward, v_up, and v_right
newmis.velocity = aim (self,1000); // a builtin that handles autoaim if turned on// with no autoaim, aim is equivalent to:
// newmis.velocity = v_forward; // 1 unit vector from aim pointer self.v_angle - where your gun is aimed

newmis.velocity = newmis.velocity * 1000;
// if you want to determine the speed from a velocity:
// float speed;
// speed = vlen(self.velocity);

newmis.angles = vectoangles (newmis.velocity); // point the rocket tip where velocity vector is going
".velocity" is a vector - it defines a direction (v_forward) and a magnitude (1000). "1000" is the "speed" of the entity.

The quake engine will now move the missile entity in the indicated direction at that rate of speed.
To make a homing missile: design a missile think function that adjusts the missiles velocity and speed to track a target.
Note: homing missiles typically move slower than standard rockets.

Comments
TheHappyFriar
TheHappyFriar

Thanks for keeping the Quake info flowing!

Reply Good karma Bad karma+2 votes
numbersix Author
numbersix

Your welcome. :-) Sharing the knowledge gives me more motivation to work on quake stuff.

Reply Good karma+1 vote
numbersix Author
numbersix

Quake C manual ver 3.4 entries for movement:

6.2 Definition of entity fields

Movement in 3D

vector velocity; // = 'speed_x speed_y speed_z'
vector avelocity; // = 'pitch_speed yaw_speed 0', angle velocity
vector punchangle; // temp angle adjust from damage or recoil
float movetype; // type of movement
float yaw_speed; // rotation speed
float solid; // tell if entity can block the movements.

Reply Good karma+1 vote
Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

Follow Report Profile
Icon
Quake
Platforms
Windows, Mac, Linux, DOS, N64, DC
Developer & Publisher
id Software
Engine
Quake Engine
Contact
Send Message
Homepage
Idsoftware.com
Release date
Game watch
Follow
Tutorial
Browse
Tutorials
Report
Report
Share
Related Games
Quake
Quake First Person Shooter
Related Engines
Quake Engine
Quake Engine GPL
Related Groups
id Software
id Software Developer & Publisher
qc
qc Hardware & Tech with 32 members
QuakeDB
QuakeDB Fans & Clans with 212 members