public void JumpTo(Vector3 position) { Node node = gridSystem.NodeFromWorlPoint(position); GameObject target = node.objectOnNode; bool canJump = false; if (target != null) { Debug.Log("Coucou !"); if (target.GetComponent <HomeObject>() != null) { Debug.Log(target.GetComponent <HomeObject>().name); if (target.GetComponent <HomeObject>().onTopObject == null) { Debug.Log("Top Object = null"); HomeObject targetObj = target.GetComponent <HomeObject>(); if (dog.height == ObjectSize.Low) { if (targetObj.size == ObjectSize.High || targetObj.size == ObjectSize.Ground) { canJump = true; } } else if (dog.height == ObjectSize.High || dog.height == ObjectSize.Ground) { if (targetObj.size == ObjectSize.Low) { canJump = true; } } } } } else if (dog.height == ObjectSize.Low && node.walkable && gridSystem.CheckIfPosIsNear(dog.gameObject, position)) { dog.JumpTo(node, false); dog.height = ObjectSize.Ground; gridSystem.CleanUpdatedNode(); return; } else { dog.BeConfused(); } if (canJump) { if (gridSystem.CheckIfObjectIsNear(dog.gameObject, target)) { if ((dog.height == ObjectSize.Ground && target.GetComponent <HomeObject>().size == ObjectSize.Low) || (dog.height == ObjectSize.Low && target.GetComponent <HomeObject>().size == ObjectSize.High)) { dog.JumpTo(node, true); } else { dog.JumpTo(node, false); } dog.height = target.GetComponent <HomeObject>().size; gridSystem.CleanUpdatedNode(); gridSystem.UpdateWalkableNode(dog.height, node); } } else { dog.BeConfused(); } }