- Home /
Adjusting transform (up, forward, whatnot)
EDIT: My scripts work fine! My question is about proper usage of the Transform object and it's subordinate vectors. Please read carefully.
I've been writing scripts that make adjustments to some of the transform vectors. Take for instance a script that controls a missile tracking a target. I make some vectors and determine how much of an adjustment to make based on the allowed turning rate of the missile. Then I simply add the offset to transform.forward.
Does this make sense? Should I be using the Rotate method or Quaternions instead of this kind of direct modification?
Things seem to be working properly but does Transform automatically normalize and fix the other direction vectors when you modify one?
If people are going to downvote something - at least give a reason so the asker knows what they've done...
I'm not sure I understand what you're asking. Are you making modifications to the standard Vector3.up, Vector3.forward, etc.? As in Vector3.up = Vector3(0.53, 0.89, 0.1); and stuff like that? I didn't think that was possible, but that could just be my assumption because I'd never want to actually change them.
It sound like you want to have a smart missile that tracks the position of your target. A lot of player type aircraft uses evasive maneuvers thus avoiding missiles. Simply set your positional coordinate values of the missile incrementally towards that of your target.
Thanks CSDG
@Byterunner.. No, I'm not changing the standard 'forward'. I'm changing gameObject.transform.forward. And it works, but I've never seen a reference to it so I'm wondering if that is crazy or not.
Answer by UniteMage · May 24, 2011 at 10:22 PM
Basic Chasing and Evading
if (missleX > targetX) missleX--;
if (missleX < targetX) missleX++;
Do the same for the other axes. Of course this is an over simplification.
Thanks CSDG
http://www.gotow.net/andrew/blog/?page_id=78 take a look at the AI for steering left/right. It's a very good system. Simply calculate the relative position and apply steering based on it.
$$anonymous$$y tracking scripts work fine. $$anonymous$$y question was about the validity of directly modifying gameObject.transform.forward.. on the missile itself.
Your answer
![](https://koobas.hobune.stream/wayback/20220612083622im_/https://answers.unity.com/themes/thub/images/avi.jpg)