Help with elite programming problem

Blitz3D Forums/Blitz3D Programming/Help with elite programming problem

*(Posted 2006) [#1]
I have created a basic elite combat system but for some reason the ship doesnt point towards the target, it pitches and rolls so its in view but then goes wild. Anyone have any ideas on how to fix this one? Ive been working on it a while but I can get it close but it still doesnt work 100% strangely the angles I have dont point directly towards the target.

you can download the source and model here

Thanks for your help


puki(Posted 2006) [#2]
Personally, I'd let Blitz handle that rather than trying to calculate it. I'd take the easy route as I'm no good at maths and stuff like that.


fredborg(Posted 2006) [#3]
I haven't looked at your code, but you should be able to simply use AlignToVector along the lines of this:
dirx# = targetx - EntityX(ship,True)
diry# = targety - EntityY(ship,True)
dirz# = targetz - EntityZ(ship,True)

AlignToVector ship,dirx,diry,dirz,3,0.01

; And if you want to keep the ship up straight add this:
; AlignToVector ship,0,1,0,2,0.01
The 0.01 part determines the speed of the change/alignement.

As I said, I haven't looked at your code, but this should work flawlessly.


*(Posted 2006) [#4]
fredborg: Thanks will have a look :)

Puki: Blitz doesnt seem to rotate it right this is why I wanted to do the math route :)


dynaman(Posted 2006) [#5]
I'm not any help on the rotation. I just wanted to say I'm happy to see your still working on this one!


_PJ_(Posted 2006) [#6]
Dont forget the roll parameter for using PointEntity. I had similar issues with some of the game-engine stuff in Galactic Allegiance.

UNfortunately, my main PC's out of action at the mo, (which means so's Blitz and my sourcecode) if this isnt sorted by about 7 days time, Il get back to you.


Ricky Smith(Posted 2006) [#7]
For full 360 degree rotation on any axis you could try to use Quaternions ( or matrices). Euler angles are not very good for this purpose due to gimbal lock - which may be what you are experiencing.
You should try and only use Eulers at the first and last stage of converting to/from a quat or matrix.


Stevie G(Posted 2006) [#8]
Use Aligntovector as fredborg says. This command uses quats internally so I'd suggest using these to align on roll and pitch axis and avoid the dreaded Gimbal Lock.

When flying in Elite the general idea was to roll until the ship was directly above you then pitch to match.

Stevie


*(Posted 2006) [#9]
fredborg: The function you provides is brilliant for missiles but Elite ships only use pitch and roll to point towards thier target, they roll till the target is on the y axis then pitch up/down till they are in the firing line.

I.e. the ship rolls left or right till and pitches up and down till the target is directly in front of the ship. I can get the basics but it always seems to be a little off.


Nicstt(Posted 2006) [#10]
Loved the original Elite, east to drop in for a few minutes, 'modern' versions require too much time investment.

Played Elite and Dungeon Master all that time ago, still great:)

Great job on this been watching for a while now, hoping to give it a go when its finished:)


*(Posted 2006) [#11]
Played Elite when it was released on the BBC :), got hooked from there.


Damien Sturdy(Posted 2006) [#12]
Good luck, Commander Jameson.


*(Posted 2006) [#13]
Anyone have any way of doing this, im still looking at me code trying to make it as smooth as possible.


Stevie G(Posted 2006) [#14]
I've just downloaded this so I'll have a play around. Assume you don't mind if I change a few things? I can't help thinking there is a much easier way than you're currently using ;)

I'll post back with results later.

Stevie


Stevie G(Posted 2006) [#15]
Ok, I came up with this stripped down version of your code. Press and hold T to target the space station, hit SPACE to randomly place and rotate the Ship. Cursors to roll + pitch.

It's not perfect but should do the job and hopefully makes sense to you.



Stevie


gpete(Posted 2006) [#16]
nice StevieG, i just had an elite flashback with your code!


*(Posted 2006) [#17]
Thanks will have a look :)


*(Posted 2006) [#18]
Thanks Stevie G thats exactly what im looking for :)