Need help figuring out object detection/Figuring out SphereCast
Hello everyone. Rookie Unity coder here. I've recently been trying to work on my first game in unity which is meant to feature a grid based movement system for its primary gameplay. Akin to a strategy RPG like Fire Emblem or Xcom. I've made a simple script that allows me to move a marker around the map grid. It works well enough for that however the issue is in the fact that I can't seem to figure out how to make it not phase through walls. Allow me to elaborate.
Here's the script. It works by moving an invisible object called movePosition one meter towards north, south, east or west depending on directional input and then moving the marker object towards it. What I want to figure out is how to not allow the movePosition object to end up inside a wall. I tried using SphereCast to check for objects on the layer "blockingTerrain" in every direction using a pair of if statements but I just couldn't make sense of how it's supposed to work.
Here's an example of what it looks like with my attempts to use ShpereCast
(Note that I'd forgotten to include the exclaimation points to invert the if statements in the screenshots but it doesn't seem to work with or without them) The console gives me these compile errors: Arguement 1/3 Cannot convert float to UnityEngine.Vector3 and Arguement 4 must be passed with the 'out' keyword
If anyone knows how to fix this I'd greatly appreciate the help. And if anyone needs more information I'll gladly provide it.
Thank you in advance
Your answer

Follow this Question
Related Questions
[Help] BoxCast doesn’t recognize object into it !! 0 Answers
Is it possible to put collision detection in an if statement? 0 Answers
How does hinge joint work? 0 Answers
Two Vectors Beetween Angle 0 Answers
Move rigidbody cube without it tumbling 2 Answers