#Regarding Rec Room AI
1 messages · Page 1 of 1 (latest)
So they can patrol the base and if they see someone on the enemy team then it will book it towards them with 200 health and you gotta shoot them down and then once there are no enemies in its line of sight then it returns to the closest point on its patrol route
for the turret:
YOU SHOULD READ #1321098169693507604 TO UNDERSTAND ALL THAT
- make a turret where the base and the gun is 2 separate objects
- clamp the turret to a vector component (this will be your pivot) and clam projectile launcher too (this will be the shooting part)
- now onto the chips:
the detection part:
create a player list variable named "Possible targets"
create a player variable named "Current target"
event receiver (Update 30Hz) > overlap sphere (position is gun position, radius is how far you want your gun to look) > list clear (connect "Possible targets" to it)for each (connect yellow output of overlap sphere to yellow input of for each) > if player is valid (connect to yellow output of for each) > if player has role (check if current player has role of enemy team, connect yellow output of for each) > if (ray cast (position is projectile launcher position, direction is [current player position (yellow output from for each > get position) - projectile launcher position]) = current player (yellow output from for each)) > list add (connect "Possible targets" to it)
this might look scary but its what cv2 is about
the rotate part:
event receiver (Update (NOT 30Hz, enable beta content to select this)) > "Current target"(connect yellow input to "get closest" (connect the "possible targets" list)) > set rotation (target is vector component that you clamped the gun to, the rotation is: [("current target" position + ("current target" velocity * "Vector3 distance"(current target pos, gun pos) / bullet speed)) - gun position])
the shoot part:
event receiver (Update 30Hz) > custom cooldown (cooldown is interval between shots) > if ("Vector3 dot" ([(just connect the whole "get future position of target" part from previous thing to reduce circuit count) - gun pos], gun rotation) >= 0,7(this is precision at which it will shoot, 1 = when it looks directly at target, -1 when it looks the opposite direction) > shoot the projectile launcher
excpect bugs from this because i may've made mistakes
I’ll try myself