How to make an entity follow a player

Discussion in 'Mapping Questions & Discussion' started by I Darkstar X, May 16, 2018.

  1. I Darkstar X

    I Darkstar X L1: Registered

    Messages:
    42
    Positive Ratings:
    5
    OK, so, I wanted to make a map with a big scary turret thing that aims its big ol' energy beam shooty-mc-shoot gun at players as they come close. Ideally, I'd like it to be able to target the closest player as they become available, then shoot its beam of death at them. If a player breaks line-of-sight, it would repick the nearest target to focus on and shoot some more.

    BUT

    I wanted to make sure I could do something like this first. At its very most basic, the turret would be a block brush with a smaller brush entity at the top that dynamically aims itself at players as they get close. To therefore test this, I made a small map with a pyramid that is supposed to rotate to look at players as they enter the cube its in.

    But, of course, I encountered some complications.

    Currently, I have the pyramid being a func_brush parented to a point_viewcontrol at its origin. There is a handy-dandy info_target that gets parented to the head of a player by a logic_auto. The point_viewcontrol is set to point at the info_target, so, theoretically, as the point_viewcontrol rotates to look at the player, it should also rotate the pyramid.

    But nope. Its annoyingly not doing what I want. Plus, I'm not even sure if it will switch to the closest player as I want it too if they die. It doesn't respect line of sight either, which I anticipate will require me to manually manage via a trigger multiple enveloping all areas that it can see too. (Though of course I wouldn't actually want to do this and if its possible to have it respect LOS that would be GREAT!)

    I have included the BSP for experimentation on your own to see if the many much more gifted and/or experienced mappers on this site can get it work as I hope.

    -----

    Note: If this is in fact impossible, some assistance creating a satellite that flies up above and shoots explosive lasers down below would be greatly appreciated. It doesn't even have to move, it can be static if it absolutely has to. Again, I'm not the most experienced at this sort of thing. I don't even know how to make 3D skyboxes! XD
     

    Attached Files:

  2. Egan

    aa Egan

    Messages:
    1,318
    Positive Ratings:
    1,507
    • Like Like x 1
  3. I Darkstar X

    I Darkstar X L1: Registered

    Messages:
    42
    Positive Ratings:
    5
    This is really good stuff, but It seems to be that it can only rotate left and right, not up and down, fully dynamically as I would like it to.

    Perhaps I'm asking too much XD Maybe I can try an "Obelisk of Light" sort of thing and have a static tower that charges up and shoots a beam at people with a lock-on laser... somehow...

    Any ideas on that?
     
  4. Egan

    aa Egan

    Messages:
    1,318
    Positive Ratings:
    1,507
    You should be able to use an env_laser or a env_beam , and put player as the target to have it automatically randomly strike a player. It may only work with targetnames though, in which case you will need to use the addoutput io to modify the targetname keyvalue of the player using a trigger. The beam/laser will auto aim and strike the player, and you can modify its width however you want.

    Otherwise you can try using the 2nd tutorial link's system of controlling a weapon and using the tf_weapon_point_mimic to fire actual projectiles like rockets out in front of the gun.
     
    • Thanks Thanks x 1
  5. Werewolf

    aa Werewolf Probably not a real Werewolf

    Messages:
    779
    Positive Ratings:
    226
    You can use a light_dynamic and a parent-able named entity. Way back I needed a spotlight that followed players around, and @Tumbolisu provided an example .vmf. (My original spotlight thread - https://tf2maps.net/threads/creating-a-player-tracking-spotlight.24115/)

    The thing about light_dynamic is that you can set it so it doesn't actually cast any light, but it still moves around. I have parented props to it to make it look like the prop was tracking a player, such as a CCTV camera.

    As for it not firing when the player is in cover, I presume you'd be using static world geometry meaning you'll know what areas they will be safe in. I would place trigger_multiple brushes in those areas and set them up so if the player enters that area it disabled your weapon from firing. Maybe after a enough time it can also 'lose' it's target and reset to it's default state.
     
    • Thanks Thanks x 1
  6. I Darkstar X

    I Darkstar X L1: Registered

    Messages:
    42
    Positive Ratings:
    5
    GREAT SUCCESS FRIENDOS!

    It rotates dynamically, it acquires targets, it shoots AND detonates stickies and boy-howdy does it want to kill some people! Thanks for the help, everyone! If you like, I can release a very small proof-of-concept map with it for your testing pleasure. (As I can't insert VMFs into these replies, annoyingly.)
     
  7. Sir Nick

    Sir Nick L1: Registered

    Messages:
    19
    Positive Ratings:
    3
    That sounds like a fairly complicated set of logic, and one that someone in the future might find great use in dissecting. If you're willing to post a .vmf with a working model, I say go for it.
     
    • Agree Agree x 1
  8. I Darkstar X

    I Darkstar X L1: Registered

    Messages:
    42
    Positive Ratings:
    5
    Alright! ^^ I put it up, with the .bsp and the .vmf in a .zip folder. You can download it here.
     
  9. I Darkstar X

    I Darkstar X L1: Registered

    Messages:
    42
    Positive Ratings:
    5
    I made another one that is FAR FAR more of a TF2 experience than the one above. Here it is. I'd love to hear your opinion(s) on it! ^^