View Single Post
Smilex_Gamer
Senior Member
Join Date: Apr 2017
Location: Portugal
Old 09-24-2019 , 11:06   Re: How to create circle
Reply With Quote #7

Quote:
Originally Posted by Natsheh View Post
Lmao I didn't think this through typing it, I mean I want create a circle in multiple directions and check if the player is in it lets say it's more like player inside cylinder I want to give width to that circle/cylinder I'm using this equation to detect how far the player from the circle in different axis (PlayerOriginX - circleCenterX )^2 + floatsqroot((PlayerOriginY - circleCenterY)^2)) < Radius

I'll post what I have tried after I come back from work.
First: A circle is 2D. A cylinder is 3D.
Maybe you're trying to know if a player is inside a sphere.
If that's so, the formula to know if something is inside that sphere is this one: (x - SphereCenterX)^2 + (y - SphereCenterY)^2 + (z - SphereCenterZ)^2 < Radius^2
If it's a circle, then it's: (x - CircleCenterX)^2 + (y - CircleCenterY)^2 < Radius^2

P.S: The only thing you got wrong in your formula was the radius that wasn't square rooted.
P.S.S: Of course, because Goldsource is a 3D game engine, your circle you create has a Z origin, so you should use the first formula in my comment.

Last edited by Smilex_Gamer; 09-24-2019 at 11:23.
Smilex_Gamer is offline