I need to align a shadow sprite below a car mesh onto a track mesh.
Currently I'm using the code below.
"temppivot" is just a temporary b3d pivot.
"mesh" is the car
"shadow" is a b3d sprite for the shadow
I'm performing a vertical linepick straight down from the car onto the track. If it hits the track, the following code is performed.
The problem is that the track mesh is not flat, it has cambers and hills in all directions, and I *must* point the shadow sprite in the same direction as the car (it's a proper car shaped shadow, not a round blob) so I'm rotating it around the Y axis with the line - RotateEntity shadow,0,EntityYaw#(mesh,True),0
It ALMOST works but on hills as the car turns to run across the hill (so the hill is sloping upwards from left to right relative to the car) the shadow does not follow its yaw correctly, always being rotated off by a few degrees.
When the car points straight up or down the hill it works OK.
Can anyone help me with this? There must be a simple solution.
Currently I'm using the code below.
"temppivot" is just a temporary b3d pivot.
"mesh" is the car
"shadow" is a b3d sprite for the shadow
I'm performing a vertical linepick straight down from the car onto the track. If it hits the track, the following code is performed.
The problem is that the track mesh is not flat, it has cambers and hills in all directions, and I *must* point the shadow sprite in the same direction as the car (it's a proper car shaped shadow, not a round blob) so I'm rotating it around the Y axis with the line - RotateEntity shadow,0,EntityYaw#(mesh,True),0
It ALMOST works but on hills as the car turns to run across the hill (so the hill is sloping upwards from left to right relative to the car) the shadow does not follow its yaw correctly, always being rotated off by a few degrees.
When the car points straight up or down the hill it works OK.
Can anyone help me with this? There must be a simple solution.
PositionEntity temppivot,PickedX#(),PickedY#(),PickedZ#(),True dist# = EntityDistance#(temppivot,mesh) alpha# = 1.0 - ((1.0 / 10.0) * dist#) If (alpha# > 1.0) alpha# = 1.0 If (alpha# < 0.0) alpha# = 0.0 PositionEntity shadow,PickedX#(),PickedY#(),PickedZ#(),True RotateEntity shadow,0,EntityYaw#(mesh,True),0 AlignToVector shadow,-PickedNX#(),-PickedNY#(),-PickedNZ#(),1,1 AlignToVector shadow,-PickedNX#(),-PickedNY#(),-PickedNZ#(),3,1 EntityAlpha shadow,alpha# ScaleSprite shadow,((alpha#) * 3.5),((alpha#) * 3.5) MoveEntity shadow,0,0,-0.05;-0.025