Spawn entities in real-time
Moderator: InsideQC Admins
7 posts
• Page 1 of 1
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).
- JasonX
- Posts: 411
- Joined: Tue Apr 21, 2009 2:08 pm
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.
-

ceriux - Posts: 2223
- Joined: Sat Sep 06, 2008 3:30 pm
- Location: Indiana, USA
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
- leileilol
- Posts: 2783
- Joined: Fri Oct 15, 2004 3:23 am
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?
- JasonX
- Posts: 411
- Joined: Tue Apr 21, 2009 2:08 pm
Re: Spawn entities in real-time
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?
Yes. Do a traceline, and set the new entity origin as trace_endpos:
- 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);
-

mankrip - Posts: 915
- Joined: Fri Jul 04, 2008 3:02 am
Re: Spawn entities in real-time
mankrip wrote: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?
Yes. Do a traceline, and set the new entity origin as trace_endpos:
- 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);
Wow! It works perfectly. Thank you!
- JasonX
- Posts: 411
- Joined: Tue Apr 21, 2009 2:08 pm
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
