Point In Front of SpaceShip

Blitz3D Forums/Blitz3D Programming/Point In Front of SpaceShip

Teffo(Posted 2005) [#1]
Say I have a spaceship with it's pitch,yaw,roll being constantly adjusted, and my goal is to put a object infront of the ship say 10000 units away - what are the sin/cos code portions to do this - or is there another way?

Teff


semar(Posted 2005) [#2]
put a object infront of the ship say 10000 units away

Well, I'll try this way:
1) create the object parented to the ship; in this way, it will be at 0,0,0 related to the ship, and 'oriented' as the ship:

cube = createcube(myship)

2) unparent the object with:
SetEntityParent cube,0

3) move the object 10000 units far away with:
MoveEntity cube, 0,0,10000

Note: if you need to move the object so that it stays always in front of the ship when the ship moves, you may not need the unparent bit.

Hope this has sense for you,
Sergio.


sswift(Posted 2005) [#3]
TFormPoint 0, 0, 1, Ship, 0
X# = TFormedX()
Y# = TFormedY()
Z# = TFormedZ()

That will tell you the position in global space of a point 1 unit in front of your ship in ship space.

If your ship is scaled down by 50%, ie, 0.5, then you'll have to increase that distance to compensate, by the opposite amount. 1.0/Scale#, which in this case would be 2.


D4NM4N(Posted 2005) [#4]
i beleive all u need:

thinginfront=createpivot(plane)
moveentity thinginfront,0,0,distance


Teffo(Posted 2005) [#5]
I tried sswift's example and it worked exactly after refering to the help!
--and the pivot is also a good solution

Thanks
Teff