I'm working on a wall-running feature in a 3D game. When the player presses the button, the monster dashes forward. If he bumps into a wall, he should start his wall-run, otherwise he should continue in his normal state. I tried to use hit.nx so I could get the normal to the hit surface and rotate the monster's tilt to be parallel to that normal. The problem is hit.nx seems to only return a value if an entity was hit, but not if a level block was hit. That's exactly the opposite of what I'm trying to do.
A better way to go about this please?
Code:
if(my.state == 12) //Obilicleon Wall-Running
        {
        	while(key_enter || joy_3)
		    wait(1);
	       	
	       	while(my.state == 12)
	       	{
	       		while((dash<100) && WallRunning == 0)
	       		{
	       			dash += 10 * time_step;
	   		        my.animation = 75; //75% animation frame is run3
	   		        ent_animate(me, "run", my.animation, 0);
	   	            c_move(me, vector(dash*time_step, 0, 0), vector(0, 0, -distancedown), USE_POLYGON |IGNORE_PASSABLE);
	                if((dash > 100) && (hit.nx != 0))
	                {
	                	dash = 0; my.animation = 0; WallRunning = 1;
	                	my.roll += 90; //temporary. Will replace with code to orient model to normal of hit surface
	       	            CameraChaseWallRun(me);
	                }
	                else if((dash>100) && hit.nx == 0)
	                {my.state = 3;} //state that waits for button release before reverting to state 1
	                wait(1);
       			}
....rest of wall-run state code
	       	}

}