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?

more ▼

asked May 23, 2011 at 09:56 PM

avatar image

5.7k 48 43 75

Why would anyone downvote this?

May 24, 2011 at 09:40 PM flaviusxvii

If people are going to downvote something - at least give a reason so the asker knows what they've done...

May 24, 2011 at 09:46 PM GesterX

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.

May 24, 2011 at 09:54 PM Byterunner

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

May 24, 2011 at 10:12 PM UniteMage

@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.

May 24, 2011 at 10:27 PM flaviusxvii
show all comments (comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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

more ▼

answered May 24, 2011 at 10:22 PM

avatar image

134 91 64 70

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.

May 24, 2011 at 10:27 PM Joshua

My tracking scripts work fine. My question was about the validity of directly modifying gameObject.transform.forward.. on the missile itself.

May 24, 2011 at 10:28 PM flaviusxvii
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: May 23, 2011 at 09:56 PM

Seen: 2117 times

Last Updated: May 25, 2011 at 12:54 AM