3D Line
Blitz3D Forums/Blitz3D Programming/3D Line
| ||
Hi. I am close. I have two balls that are positioned randomly in 3 spaces. Then I make a small square appear between them. Then I scale the square the amount of the distance between the two balls...so far so good. However, the problem is I don't know how to rotate the line in the center to connect to the two balls. I tried pointentity and that doesn't work. Any ideas? Thanks! Fader |
| ||
What happened when you tried PointEntity? I'm guessing that if you try scaling your square with the line length on a different axis your PointEntity should work. eg, if your current scaleentity is something like ScaleEntity lineentity,distance#,1,1 try ScaleEntity lineentity,1,distance#,1 or ScaleEntity lineentity,1,1,distance# I'm not sure which axis PointEntity uses to point but trying them all on the scaling should find it eventually. |
| ||
here's a nice routine by chroma:;=========================== ;Point Entity at x,y,z ;=========================== Function Point_Entity(entity,x#,y#,z#) xdiff# = EntityX(entity)-x# ydiff# = EntityY(entity)-y# zdiff# = EntityZ(entity)-z# dist#=Sqr#((xdiff#*xdiff#)+(zdiff#*zdiff#)) pitch# = ATan2(ydiff#,dist#) yaw# = ATan2(xdiff#,-zdiff#) RotateEntity entity,pitch#,yaw#,0 End Function ;=========================== if it turns out to be pointing 90 degrees away, try scaleing on different axis. |
| ||
Chroma's function worked! Thanks! But why didn't pointentity work? I tried scaling on all different axises. Thanks, Fader |
| ||
I'm not sure why pointentity doesn't work. But oh well. Chroma's function is more flexible anywho. |