how can i change the boolean to true in this case????

#pragma strict
static var isdodge : boolean;
var direction;
var hit : RaycastHit;
var estranho : GameObject;
function Start () {
direction = transform.TransformDirection (Vector3.up);
isdodge = false;
}
function Update () {
Debug.DrawLine (transform.position, hit.point, Color.red);
if (Physics.Raycast ( transform.position, direction , hit,20)){
isdodge = true;

I’m trying to assign true when isn’t colide anymore
if (!Physics.Raycast ( transform.position, direction , hit,20)){ == does’nt work
isdodge = false;

i tried use else,but doen’t work properly,someone could help me?
thanks in advanced

Either one of those things should work. You might need to do more checking to see if it’s doing what you think. For instance, add a Debug.Log(“raycast hit”) or something in the brackets so you can see if it’s actually hitting in the first place, or maybe it’s hitting something all the time. You aren’t testing to see what you hit. Your logic is correct, though. You don’t have the end brackets, but I assume that’s because you aren’t showing all your code. An if/else would probably be the best in that circumstance, so it gets changed from true to false and back.

ok thank you