Posted By: FoxHound
Make AI look ahead an dprepare for a turn - 05/11/11 05:02
I'm setting up a race game and have attached a car to a path. I'm making it move around an oval track. I want to make the car look at the next five nodes and look at the angel difference between them. However I am having a bit of a problem comming up with a good solution.
Issue with this is the numbers are not constant for what is happening on the world. I have a higher value for going on the straights than i could have going around the curves, but not constant enough for me to understand why.
Code:
for(i = 1; i < 5; i++) { if((cur_node + 1) > my.number_of_nodes_on_my_path) { cur_node = 0; } path_getnode(my,cur_node + i,NEW_POSITION,NULL); //------------------------------------------- b = vec_dot(OLD_POSITION,NEW_POSITION) / ( vec_length(OLD_POSITION ) * vec_length(NEW_POSITION) ) ; if(b < 0) b *= -1;//no negative numbers around here a += b; vec_set(OLD_POSITION,NEW_POSITION); }//end of for loop
Issue with this is the numbers are not constant for what is happening on the world. I have a higher value for going on the straights than i could have going around the curves, but not constant enough for me to understand why.