well, if the shadow is under a car ... just put it there ..
Also, if you want the shadow moving smoothly over a hill top,
that's hard. You'll need an extra dummy object, and attach the shadow as a limb. Then, use trig to determine the pitch/roll
of the terrain under the shadow and rotate the shadow limb as needed. The code is hard to write the first time, after that, you can save it in an archive as a refrence ....
function PitchandRoll(p)
foot#=10.0
`front
ta#=RPlayer#( P ,1, _Cay )
bx#=RPlayer#( P ,1, _X )
bz#=RPlayer#( P ,1, _Z )
by#=RPlayer#( P,1, _Y )
flx#=NewXValue(bx#,ta#,foot#)
flz#=NewZValue(bz#,ta#,foot#)
`fast method....?
`flx#=bx#+FastXYZ#(ta#,1)
`flz#=bz#+FastXYZ#(ta#,3)
fly#=Get Ground Height(1,flx#,flz#)
foot#=FastRange(abs(bx#-flx#),abs(by#-fly#),abs(bz#-flz#))
pa#=wrapvalue(ACos((fly#-by#)/foot#)-90)
`fast method...
`pa#=FastACos(15+(fly#-by#),foot#)
`right
foot#=10.0
ta#=WrapValue(RPlayer#( P ,1, _Cay )+90.0)
frx#=NewXValue(bx#,ta#,foot#)
frz#=NewZValue(bz#,ta#,foot#)
`frx#=bx#+FastXYZ#(ta#,1)
`frz#=bz#+FastXYZ#(ta#,3)
fry#=Get Ground Height(1,frx#,frz#)
foot#=FastRange(abs(bx#-frx#),abs(by#-fry#),abs(bz#-frz#))
ra#=wrapvalue(ACos((by#-fry#)/foot#)-90)
`ra#=FastACos(15-(by#-fry#),foot#)
dobj=RPlayer#(p,1, _TID )
position object dobj,RPlayer#(p,1, _X ),-1000,RPlayer#(p,1, _Z )
rotate object RPlayer#(p,1, _RID ),pa#,0,ra#
YRotate object dobj,RPlayer#(p,1, _CAY )
Position Object dobj,RPlayer#(p,1, _x ),RPlayer#(p,1, _Y ),RPlayer#(p,1, _Z )
endfunction
That code will not work as written because:
1 - source is in DarkEdit
2 - Calls external math functions
3 - Uses external defined constants ... _CAY ...
and so on.
This is just to show the math used.