Hi again.
I try to make a character movement and control out of raycasting but now I got into a problem.
Its not hitting anything although there is a collider there.
![alt text][1]
![alt text][2]
And this is the script:
using UnityEngine;
using System.Collections;
public class Controller : MonoBehaviour {
public float OnGround = 2.5f;
//Planing to add ((public Rigidbody2D rb2D;))
void Start() {
//Planing to add ((rb2D = GetComponent<Rigidbody2D>();))
}
void FixedUpdate() {
transform.Translate (Vector2.down * 0.1f);
RaycastHit2D hit = Physics2D.Raycast(this.gameObject.transform.position, Vector2.down);
if (hit.distance <= OnGround) {
print ("Stop!");
transform.Translate (Vector2.zero);
}
}
}
As I said it doesn’t detect the collider. any ideas?
Thanks for reading.
-Coaster Mind