Path: chuka.playstation.co.uk!news From: Majik Newsgroups: scee.yaroze.freetalk.english Subject: Re: Collision Detection Shortcut Update Date: Thu, 26 Feb 1998 14:31:37 +0000 Organization: Sinclair MicroComputer Museum Lines: 51 Message-ID: <34F57CC9.3A3A@127.0.0.1> References: <6caa8e$5bj12@scea> <34F3BA79.6168@bc.sympatico.ca> <34F55175.2793@mdx.ac.uk> Reply-To: majik@127.0.0.1 NNTP-Posting-Host: 194.202.250.27 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.0 (WinNT; I) Robert Swan wrote: > > Distance = abs(displaced_x) + abs(displaced_y); > > This works extremely well (ie, I can have 100 ships in 50fps) and is the > method I am using on my current version of the demo, BUT there are two > problems- > > 1) the ships only come towards you on one of the diagonals until they > can head straight towards you along one of the major compass directions. > This basically looks rubbish when you have 100 ships coming in from only > four directions. > 2) the ships are quite happy to attack you, and then sod off in the > opposite direction for infinity! This I can get over with a programming > fix, so 'tis not really a problem. > > What I'm looking for is a method with this speed, but which makes the > enemy approach from far more than four directions, and if at all > possible will overcome problem 2). I'm thinking of basing the angle the > ship should turn towards being based on using a lookup table referenced > by the value of abs(displaced_x)/abs(displaced_y) but this involves > division which is going to be too slow as well. Any ideas, anyone! Aha, now I've tried both of the above, and came to the same conclusions.. use method 2, to simply work out whether the opponent is left/right above/below of what you want, then taking its direction vector from your position perform and inverse tan on the z/x value, using this angle (0 - 90) and the above you can figure out the correct direction, and adjust the course... at least thats the thoery, I've only implemented part of this so far, so I'll be testing it tonight. Anyway first release of Combat3D will be tommorow, it'll come with source so if it works, you can take a butchers... > Dear Jim, > Please, please, please could you fix it for me? I hope so... and don't call me Jim! Majik Saville (now then, now then...) -- -- Majik - Owner/Curator of the Sinclair Microcomputer Museum -- Spod in a suitcase - ' Have Compiler, will travel ' -- http://mudhole.spodnet.uk.com/~majik/ --