Spawn entities in real-time
Spawn entities in real-time
Without a modified engine, is it possible to spawn entities in real-time? I'm working on a small TD mod for Q1, but i'm curious if i'm able to spawn entities (like zombies, or dogs) to attack my enemies, as well boxes and other models (to block the way).
Re: Spawn entities in real-time
i did it. i think you just spawn a spawn entity at the position you want but only spawn the monster according to some variable.
Re: Spawn entities in real-time
You can spawn entities in real-time, it's just the precaching you can't do in real-time - because it's not really precaching if you do it post-load. So you'd have to make the precaching bit in a conditional and precache the relevant monster stuff in another init funciton.
i should not be here
Re: Spawn entities in real-time
Alright, thank you guys! Another quick question: with QC, can i grab the player view point, so i can spawn an entity where the player is looking at? Like a bullet?
Re: Spawn entities in real-time
Yes. Do a traceline, and set the new entity origin as trace_endpos:JasonX wrote:Alright, thank you guys! Another quick question: with QC, can i grab the player view point, so i can spawn an entity where the player is looking at? Like a bullet?
Code: Select all
local entity myentity;
local vector org;
org = self.origin + '0 0 22';
// self must be the player
makevectors (self.v_angle); // calculate forward angle for velocity
traceline (org, org + v_forward*2000, TRUE, self);
myentity = spawn ();
// set model, solid and everything else before
setorigin (myentity, trace_endpos);
Re: Spawn entities in real-time
Wow! It works perfectly. Thank you!mankrip wrote:Yes. Do a traceline, and set the new entity origin as trace_endpos:JasonX wrote:Alright, thank you guys! Another quick question: with QC, can i grab the player view point, so i can spawn an entity where the player is looking at? Like a bullet?Code: Select all
local entity myentity; local vector org; org = self.origin + '0 0 22'; // self must be the player makevectors (self.v_angle); // calculate forward angle for velocity traceline (org, org + v_forward*2000, TRUE, self); myentity = spawn (); // set model, solid and everything else before setorigin (myentity, trace_endpos);