- Home /
Question by
unity_nRNQ_YOy0ET1aw · Mar 04, 2018 at 01:39 PM ·
c#unity 2dgrid
How do I get the object from an adjacent space 2d grid
My player has a Vector3 pos, and i want to check the tag of an object it collides.
if(Input.GetKey(KeyCode.A) && transform.position == pos && stoneTrigger(pos(x-1.0f,y,z))) {
transform.Translate(-1.0f, 0.0f, 0.0f);
transform.position = Vector3.MoveTowards(transform.position, pos, Time.deltaTime * 2*speed);
}
bool stoneTrigger(Collider2D other){
if (other.gameObject.CompareTag ("Obstacle")) {
return false;
}
return true;
}
Comment
it is an error at stoneTrigger(pos(x-1.0f,y,z))) and i don't know why
if pos is a Vector3, then you cannot write what you did. you can write pos - Vector3.left
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to move items in an (infinite) grid? 0 Answers
Instantiated objects, not reacting to lighting 1 Answer
Why the player is keep moving sometimes out of the grid area ? 0 Answers