Posted: 25th Apr 2021 12:55
how would i get a dynamic object to set its angular velocity toward a direction vector (equivale of lookat)

I have code that kinda works but i think the actualy velocity the last parameter of setobjectphysicsangularvelocity needs to be a dot product or something im not sure ?
hence why i ask cos it doesnt behave correctly
+ Code Snippet
	car as integer:check as integer:distance# as float
	car = CreateVector3(getObjectx(aivehicle.hit),getObjecty(aivehicle.hit),getObjectz(aivehicle.hit))
	check =CreateVector3(lpaths[0].nodes[aivehicle.nextCheck.counter].x,lpaths[0].nodes[aivehicle.nextCheck.counter].y,lpaths[0].nodes[aivehicle.nextCheck.counter].z)
	 distance#= GetVector3Distance( car,check )   //<500
	 //print(distance#)
	if distance#<500  
		SetObject3DPhysicsAngularVelocity( aivehicle.hit,0,lpaths[0].nodes[aivehicle.nextCheck.counter].y,0,((AIvehicle.velocity.max - AIvehicle.velocity.current) / 40) + (AIvehicle.velocity.current * 1.2) / 25)			
	endif


Its part of the new ai development that will be used for the ai of cars using a path to follow
Posted: 25th Apr 2021 14:51
I don't know if I understand correctly what you want to do....the path to follow is a serie of way points?
Posted: 25th Apr 2021 14:54
yes the lpath is an array of way points the ai cars i want to follow them
Posted: 25th Apr 2021 14:58
Ok...so I suppose you want to position you car every waypoint and make it point smoothly to next one right?
Posted: 25th Apr 2021 15:06
yes thats right
It may be a problem with the checkpoints yet but that doesnt seem to be the problem to me

lines 1338 to 1355 in game.agc displayes them as boxes if uncommented

I just think there needs to be nother calculation there in the code snippet above just not sure
Posted: 25th Apr 2021 15:12
Ok ...I will have a look at it....bear with me !
Posted: 25th Apr 2021 18:37
@fubarpk I've been looking at your code and comparing it to your old program Crazy Grand Prix . This is like looking for a needle in a haystack. . I've seen your moveVehicle funtion in old CrazyGP it works ok ....I can't find where could be the difference . What method did you use in old Ctrazy Grand Prix to make cars follow correctly the path ? did you use arraypath aswell ?
Posted: 25th Apr 2021 22:13
The method was just raycasting ahead if the cars too far to left turn right etc (in movevehicle.agc aimove function)

i think it work best for tracks that started turning left


i think it has to gradually point that way but im not sure if i need to calculate the dot product