This formula will get you your angle between two objects relative to object A. from there you can write some branch code or a switch that delineates between what the different angles mean, i.e. 0 or 360 = forward, 180 = behind, 90 = side, etc. and handle your desired code from there.