Align object

Blitz3D Forums/Blitz3D Programming/Align object

RifRaf(Posted 2003) [#1]
Ok, i know this is very simple, but cant get it to work. all I want to do is have a cube move around an area.. when this cube goes up hill or downhill, or on a slope of any kiND i want it to tilt with the slope. I cant sem to get alignentity to work right.. help please

sorry for the double post , didnt get many reads in the other topic.


Rob(Posted 2003) [#2]
You need to use AlignToVector ent,NX#,NY#,NZ#,axis

Ent is the entity to rotate.

You get nx etc by returning the collision normals. ie. CollisionNX.

Axis is 0,1,2 and represents X,Y,Z angle.


RifRaf(Posted 2003) [#3]
EDIT : I GO IT. THANKS ROB
COULD YOU TELL ME WHY THIS ISNT WORKING

If EntityCollided(CAR(AC),1) Then
AlignToVector car(ac),CollisionNX(CAR(AC),1),0,CollisionNZ(CAR(AC),1),1,.01
AlignToVector car(ac),CollisionNX(CAR(AC),1),0,CollisionNZ(CAR(AC),1),3,.01
EndIf

CAR DOES FINE ON FLATS.. on a slope it wants to turn all the way over 90 degrees, so that its facing straight down.. slope is only about 30-45 degrees, after that it doesnt recover.


Nek(Posted 2003) [#4]
i hope this will help
n=object
the 4 sphere i place at the four corners.
e.g.
frw=front right wheel

hope it helps.

;this procedure will align main object to the 4 sphere on the object.
zx#=(EntityX( frw[n],True )+EntityX( rrw[n],True ))/2
zx=zx-(EntityX( flw[n],True )+EntityX( rlw[n],True ))/2
zy#=(EntityY( frw[n],True )+EntityY( rrw[n],True ))/2
zy=zy-(EntityY( flw[n],True )+EntityY( rlw[n],True ))/2
zz#=(EntityZ( frw[n],True )+EntityZ( rrw[n],True ))/2
zz=zz-(EntityZ( flw[n],True )+EntityZ( rlw[n],True ))/2
AlignToVector mainobj,zx,zy,zz,1

zx#=(EntityX( flw[n],True )+EntityX( frw[n],True ))/2
zx=zx-(EntityX( rlw[n],True )+EntityX( rrw[n],True ))/2
zy#=(EntityY( flw[n],True )+EntityY( frw[n],True ))/2
zy=zy-(EntityY( rlw[n],True )+EntityY( rrw[n],True ))/2
zz#=(EntityZ( flw[n],True )+EntityZ( frw[n],True ))/2
zz=zz-(EntityZ( rlw[n],True )+EntityZ( rrw[n],True ))/2
AlignToVector mainobj,zx,zy,zz,3

PositionEntity(flw[n],0,0,0);position all wheels to 0,0,0
PositionEntity(frw[n],0,0,0)
PositionEntity(rlw[n],0,0,0)
PositionEntity(rrw[n],0,0,0)
ResetEntity(flw[n]);reset all wheels.& collinsons
ResetEntity(frw[n])
ResetEntity(rlw[n])
ResetEntity(rrw[n])
PositionEntity(flw[n],-.8,-1,1);position all the wheels to the four corners .
PositionEntity(frw[n],.8,-1,1)
PositionEntity(rlw[n],-.8,-1,-1)
PositionEntity(rrw[n],.8,-1,-1)


RifRaf(Posted 2003) [#5]
thanks


Wulde(Posted 2003) [#6]
There is an example in the code archives from Madjack Vehicle pitch roll without pivot which does this very nicely i think