mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-21 20:20:33 +01:00
Fix a runtime with FOV when moving diagonally (#90680)
This commit is contained in:
@@ -27,21 +27,18 @@
|
||||
var/vector_len = sqrt(abs(rel_x) ** 2 + abs(rel_y) ** 2)
|
||||
|
||||
/// Getting a direction vector
|
||||
var/dir_x
|
||||
var/dir_y
|
||||
switch(dir)
|
||||
if(SOUTH)
|
||||
dir_x = 0
|
||||
dir_y = -vector_len
|
||||
if(NORTH)
|
||||
dir_x = 0
|
||||
dir_y = vector_len
|
||||
if(EAST)
|
||||
dir_x = vector_len
|
||||
dir_y = 0
|
||||
if(WEST)
|
||||
dir_x = -vector_len
|
||||
dir_y = 0
|
||||
var/dir_x = 0 // based on east/west
|
||||
var/dir_y = 0 // based on north/south
|
||||
|
||||
if(dir & NORTH)
|
||||
dir_y += vector_len
|
||||
else if(dir & SOUTH)
|
||||
dir_y -= vector_len
|
||||
|
||||
if(dir & EAST)
|
||||
dir_x += vector_len
|
||||
else if(dir & WEST)
|
||||
dir_x -= vector_len
|
||||
|
||||
///Calculate angle
|
||||
var/angle = arccos((dir_x * rel_x + dir_y * rel_y) / (sqrt(dir_x**2 + dir_y**2) * sqrt(rel_x**2 + rel_y**2)))
|
||||
|
||||
Reference in New Issue
Block a user