Closed Thread
Page 1 of 3 123 LastLast
Results 1 to 10 of 27

Thread: Camera Bot

  1. #1
    Banned Teh1337bix's Avatar
    Join Date
    Oct 2008
    Location
    gm_bigcity
    Posts
    445

    Default Camera Bot

    Its a random bot I made. It is programmed to follow you and hover over your player's left shoulder and aim where you aim. I got the idea from some random RP server where some guy had set up RT screens in the main square and was following players around physgunning the RT camera. The use is based on that idea but now you can use any weapon you want!

    Watch the video, it'll tell you how to build it, there is only three parts, and the dupe doesn't work with my parenting for some reason.

    If you are making this yourself, make sure you use snap on tool and the expression is in the middle! The balance needs to be perfect because I haven't set up the interval components of the PID system of the rotation control. That's why the camera is parented!

    [ame="http://www.youtube.com/watch?v=nI4Vl8deoc8"]YouTube - Wiremod Camera Bot[/ame]

    Version 1.1.1 (Too glitchy to be worthy of 1.2)
    Current Features
    • The further away from you, the faster it will move towards you.
    • Ceiling Avoidance: When you walk into a room where the cieling is lower than the hover height, it will now stop, lower itself to the level of the ceiling and finally follow you in.
    • When it is lower than the player's head, it will stay further away from you than when it is above your head.
    • Basic stuck detection, a bit glitchy at times.
    • "/reset" command for chat. It resets the values in case it glitches.

    Proposed Features
    • Fix the problem where when it is knocked around and is pointing in the wrong direction, it takes a lot of time for it to turn back towards your aim position.
    • Integral components in the rotation system so you don't need to parent the camera.
    • Floor Avoidance.
    • Wall Avoidance (It's gonna be hard).
    Next Feature to be Added: Floor Avoidance

    [highlight=e2]@name CameraBot
    @outputs DBG DBG2
    @persist E:entity TargAlt MaxAlt Zpos Epos:vector2 XY:vector2
    @persist TargPos:vector2 AngP AngY AngR Dropping Stuck Printed
    @trigger none

    #frequency of execution#
    interval(20) #

    if(!chatClk(owner()))
    {
    #Store the PHX plate in the E variable on first execution#
    if(first()) {E = entity():isWeldedTo() runOnChat(1)} #

    #Reset the position of the PHX plate#
    Zpos = Eos():z() #
    Epos = vec2(Eos()) #
    #####################################

    if(clk("StuckTimer")){Stuck = 1}
    Height = 50
    if(owner():isCrouch()) {Height = 30}
    rangerFilter(E)
    rangerFilter(entity())
    StuckRD = rangerOffset(999999999,Eos(),
    owner()os():setZ(owner()os():z() + Height) - Eos())
    if(StuckRD:entity() != owner())
    {
    if(!Dropping){timer("StuckTimer",1000)}
    }
    else{Stuck = 0 stoptimer("StuckTimer")}

    if(!Stuck)
    {
    #Work out hover height and distance to keep from owner#
    if(!Dropping) #
    { #
    rangerFilter(owner()) #
    rangerFilter(E) #
    rangerFilter(entity()) #
    RD = rangerOffset(120,owner()os() + 1,vec(0,0,1)) #Aims up from owner
    rangerFilter(owner()) #
    rangerFilter(E) #
    rangerFilter(entity()) #
    RD2= rangerOffset(35,Eos(),vec(0,0,1)) #Aims up from Plate
    if(RD2:hit()){TargAlt = RD2osition():z() - 40} #
    Offset = 80 #
    if(RD:hit()) {Offset = 100 #
    MaxAlt = owner()os():z() + RD:distance() - 40 #
    TargAlt = MaxAlt - 20 #
    Dropping = 1} #
    else{TargAlt = owner()os():z() + RD:distance() - 40}#
    if(RD2:hit() & !Dropping) #
    {TargAlt = RD2osition():z() - 40} #
    } #
    elseif(Eos():z() < MaxAlt){Dropping = 0} #
    ################################################## #####

    #Work out XY position########################################## ##
    TargPos = vec2(owner():right())*Offset *-1 + vec2(owner()os())#

    #Work out force to apply and convert it to a vector#
    Z = (TargAlt+100 - Zpos) * 10 + $Zpos * -200 #
    if(!Dropping) #
    { #
    XY =(TargPos - Epos) * 10 + $Epos * -200 #
    } #
    else{XY = -$Epos * 200} #
    ApplyForce = vec(XY,Z) #
    ################################################## ##

    #Declare angle to store angular force#
    ApplyAng = ang() #

    #Work out angular force to apply and store it in the declared angle#
    AngP = E:elevation(owner():aimPos()) #
    ApplyAng = ApplyAng:setPitch(-AngP * 10 + $AngP * -1000) #
    AngY = E:bearing(owner():aimPos()) #
    ApplyAng = ApplyAng:setYaw(-AngY * 10 + $AngY * -1000) #
    AngR = E:angles():roll() #
    ApplyAng = ApplyAng:setRoll(-AngR * 10 + $AngR * -1000) #
    ################################################## ##################

    #Apply the force##########
    E:applyForce(ApplyForce) #
    E:applyAngForce(ApplyAng)#
    ##########################
    }
    elseif($Stuck == 1 & !Printed)
    {hint("\"CameraBot\" is stuck and can't reach you via a direct route!",5)
    Printed = 1}
    if($Stuck == -1)
    {hint("\"CameraBot\" is now following you and is not stuck!",5)
    Printed = 0}
    }
    elseif(lastSpoke() == owner())
    {
    if(lastSaid():sub(0,6) == "/reset")
    {hint("CamBot reset!",5)
    TargAlt = 0 MaxAlt = 0 Zpos = 0 Epos = vec2(0,0) XY = vec2(0,0)
    TargPos = vec2(0,0) AngP = 0 AngY = 0 AngR = 0 Dropping = 0
    Stuck = 0 Printed = 0
    }
    }
    #Debugging variables#
    DBG = Printed #
    DBG2= Offset #
    #####################
    [/highlight]
    Last edited by Teh1337bix; 06-23-2010 at 06:47 AM.

  2. #2
    Wire Noob CrazySpray's Avatar
    Join Date
    Jan 2009
    Posts
    3

    Default Re: Camera Bot

    That's actually really nice, very smooth movement. Good work!

  3. #3
    Banned ningaglio's Avatar
    Join Date
    Apr 2009
    Location
    On the planet earth
    Posts
    267

    Default Re: Camera Bot

    i like the way it knows the hight of the cieling and it goes down till it wont bump into it

    verry nice work

  4. #4
    Banned Teh1337bix's Avatar
    Join Date
    Oct 2008
    Location
    gm_bigcity
    Posts
    445

    Default Re: Camera Bot

    Quote Originally Posted by ningaglio View Post
    i like the way it knows the hight of the cieling and it goes down till it wont bump into it

    verry nice work
    That's me crouching. Crouching makes it hover 50 units lower. I need to add that feature though. Its hard to work out how to position it so it won't hit anything without having the actual map data.

    EDIT: I've got an idea, somehow do a ray collision from the player in an upwards direction (like a ranger facing straight up), and then from the distance, work out the minimum height to hover at. Although you can't apply that technique to walls. I'll find out a way to do that and update by tomorrow, if it's possible...

    EDIT2: I've implemented that now!
    Last edited by Teh1337bix; 07-15-2009 at 06:24 PM.

  5. #5
    Banned ningaglio's Avatar
    Join Date
    Apr 2009
    Location
    On the planet earth
    Posts
    267

    Default Re: Camera Bot

    Quote Originally Posted by Teh1337bix View Post
    That's me crouching. Crouching makes it hover 50 units lower. I need to add that feature though. Its hard to work out how to position it so it won't hit anything without having the actual map data.

    EDIT: I've got an idea, somehow do a ray collision from the player in an upwards direction (like a ranger facing straight up), and then from the distance, work out the minimum height to hover at. Although you can't apply that technique to walls. I'll find out a way to do that and update by tomorrow, if it's possible...

    your rank has just gone from "verry nice work" to "nice work"


    :P

    just kiding

  6. #6
    Banned ningaglio's Avatar
    Join Date
    Apr 2009
    Location
    On the planet earth
    Posts
    267

    Default Re: Camera Bot

    Quote Originally Posted by Teh1337bix View Post
    EDIT: I've got an idea, somehow do a ray collision from the player in an upwards direction (like a ranger facing straight up), and then from the distance, work out the minimum height to hover at. Although you can't apply that technique to walls. I'll find out a way to do that and update by tomorrow, if it's possible...
    you meen a ranger pointing up, one forward(so it will know in advance) and one in diagonal for the ones that the up and forward one cant see

    if you want i can help you dev it

  7. #7
    Banned Teh1337bix's Avatar
    Join Date
    Oct 2008
    Location
    gm_bigcity
    Posts
    445

    Default Re: Camera Bot

    Quote Originally Posted by ningaglio View Post
    you meen a ranger pointing up, one forward(so it will know in advance) and one in diagonal for the ones that the up and forward one cant see

    if you want i can help you dev it
    No, I mean one that works it out from the player some how. It calculates the distance from the player entity's position to whatever is above it. Since the player is always in front, if you calculate from the player it will know in advance. Its easier to use the magic of E2 because my parents can't be duped for some reason, so it needs to be simple so I can build it every time.

    EDIT: LOL @ "my parents can't be duped for some reason"

  8. #8
    Wiremod Helper Lyinginbedmon's Avatar
    Join Date
    Mar 2009
    Location
    England
    Posts
    2,659

    Default Re: Camera Bot

    You can use the built-in ranger to do that, by taking the Owner's position (Which is at their feet, pointing it upward (just add vec(0,0,1)) and giving a set range, then you've got the height from floor to ceiling where the owner is standing.

    You'll need to remember rangerFilter(owner()) though

    The Olympus Technologies drones, totally not SkyNet in Gmod form.
    Cronus: The Ultimate Drone, definitely SkyNet in Gmod form.
    The gBrain Project, the drone controls system that thinks it's better than you

  9. #9
    Wire Sofaking nescalona's Avatar
    Join Date
    Apr 2007
    Location
    Shoreline, Washington
    Posts
    1,299

    Default Re: Camera Bot

    Very nice video & design. I'm looking forward to seeing it with ceiling (and wall?) avoidance.

    ranger up from player -> avoid low doorways
    ranger up from bot -> avoid ceilings
    ranger left&right/forward diagonal from bot -> avoid walls

  10. #10
    Wirererer jayg20769's Avatar
    Join Date
    Jun 2008
    Posts
    322

    Default Re: Camera Bot

    Nice work, but wouldn't Cam Controller be easier to use, in terms of concealment? Thats what I use to spy on ppl in RP servers

Closed Thread
Page 1 of 3 123 LastLast

LinkBacks (?)

  1. 01-27-2010, 10:45 PM

Similar Threads

  1. Pac's camera.
    By Nicolai1 in forum Finished contraptions
    Replies: 23
    Last Post: 02-28-2009, 12:32 PM
  2. camera
    By thegtproject in forum Installation and Malfunctions Support
    Replies: 1
    Last Post: 07-29-2008, 02:31 PM
  3. Wire Camera & Camera Screen
    By turck3 in forum Ideas & Suggestions
    Replies: 7
    Last Post: 04-29-2008, 07:18 AM
  4. Camera help
    By tesseract in forum Installation and Malfunctions Support
    Replies: 2
    Last Post: 02-06-2008, 07:37 AM
  5. RT Camera
    By aklyatne in forum Ideas & Suggestions
    Replies: 1
    Last Post: 07-05-2007, 11:26 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots