I need smoke to go after the player.

Avatar
Samot
21 Posts
Posted Aug 08, 2018
I'm creating a Portal 2 level where I'm using env_smokestack to simulate a ghost. I'm using a func_tanktrain to make it move during the story. There is one point in the story where I need the ghost to chase down and kill the player (this happens if the player purposefully does something stupid that stops the story from progressing.) My first instincts on accomplishing this was to turn an invisible brush into an NPC, and have the env_smokestack parented to it. Unfortunately, I cannot find any instructions on creating a custom npc character. If anyone knows of a video or written instructions on how to do this, or if there is an easier way to accomplish this, I'd appreciate the info. Thanks.
Advertisement
Registered users don't see ads! Register now!
Avatar
Kwinten
40 Posts
Posted Aug 12, 2018
Replied 3 days later
you can use "EnableAlternatePath" of your path_tracks when the "player does something stupid"
There is no other alternative to create Npc than using path_tracks for the moment
(i have a big project involving scripts to create an AI in p2 )
Avatar
ChickenMobile
2,460 Posts
Posted Aug 30, 2018
Replied 18 days later
path_tracks are a point entity right? They could be parented to the player
Avatar
GusHan
1 Posts
Posted Jan 05, 2019 , Edited Sep 23, 2023
Replied 4 months later
Did you manage to get this effect, Samot? Seems like a cool idea. I'd love to know how to do this.
Advertisement
Registered users don't see ads! Register now!
Avatar
ChickenMobile
2,460 Posts
Posted Jan 06, 2019
Replied 20 hours later
It is possible to implement this idea using a vscript.

You can change the position and rotation of the ghost by working out the vector between itself and the player then moving it 'x' distance. This is called Linear Interpolation (google lerp function). Because it is a 'ghost' you don't need to figure out any pathing logic - though could still be done using functions like TraceLine(Vector, Vector, handle).

Below is code that would make an object follow the player at 10 units per/s. I used a dynamic model with the think function of think for testing.

// Speed of movement of the thing
x <- 10

// Set the direction of this entity to face the player
function think() {
   local p = player.GetOrigin()
   local s = self.GetOrigin()
   local d = p - s // The difference between this angles and the players
   self.SetForwardVector(d) // Set the angles of the object to face the placer
   self.SetOrigin(self.GetForwardVector() * x + s) // Move x units forward from original vector
}

See https://developer.valvesoftware.com/wik ... _Functions for a full list of Portal 2 scripting functions.