- Home /
Space fighter banking
I've seen similar questions asked before, but they're all about making a fighter bank based on player input. I'm trying to make my enemy fighters bank. Here's what I've got so far:
var relativePos = fightertarget.position - transform.position;
var fighterRotation = Quaternion.Slerp (transform.rotation, Quaternion.LookRotation(relativePos), TurnRate * Time.deltaTime);
//banking on turns! Somehow!
transform.rotation = fighterRotation ;
transform.Translate(Vector3.forward *0.1);
Which is pretty much a basic homing script. I can't really get my head round Quaternions (yet) so it's kicking my backside. I've tried numerous different approaches, but nothing has worked so far.
Shame you didn't get any answers to this, but I'm still curious how far did you got with this? And I assume you made them move towards the player somehow (AI), did you find an effective method of doing that?
I didn't really get any further with it. I prioritised working on other aspects with a view to getting back to this later on. I'm getting there slowly :)
Answer by Jujo100 · Jun 04, 2013 at 12:14 AM
Couldn't you just rotate the enemy around it's local Z axis based on the TurnRate? You can use this http://docs.unity3d.com/Documentation/ScriptReference/Transform.Rotate.html which defaults to local space if you leave out the last parameter.
To determine which way to bank. You would need to know if the player is on the left or right of the enemy. Someone has explained how to do this here : http://answers.unity3d.com/questions/13033/how-to-determine-if-enemy-is-on-my-left-or-right-h.html
That's actually potentially quite useful. Thanks for that, I'll give it a go.
Your answer
Follow this Question
Related Questions
Smooth Space Flight Script 1 Answer
How do I use the mouse to control a spacecraft like in this game? 1 Answer
Unity mouse trackball? (i guess it is called that) (c#) 1 Answer
Fly-By-Wire System 0 Answers
Space Flight Script 1 Answer