Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
UScript Tutorial.doc
Скачиваний:
4
Добавлен:
01.09.2019
Размер:
634.37 Кб
Скачать

Vectors and Rotators

function VectorRotator()

{

local rotator VectRot;

local vector SomeVector;

VectRot = Player.ViewRotation;

VectRot.Yaw = VectRot.Yaw + 8192;

SomeVector = Vector(VectRot);

}

Note that this is all assuming "Player" is an actor reference variable set equal to some PlayerPawn. Anyway, what's going on here? Well, first, VectRot is set equal to the player's view rotation. Then, 8192 (45 degrees) is added to its yaw, making it point 45 degrees to the player's right. Finally, SomeVector is set equal to "Vector(VectRot)". The Vector() function simply takes a rotator, and returns a vector pointing in the same direction as the rotator, with a length (speed) of one. So, now you have an easy way of getting a vector that points in any direction. But what about its speed? What if you want a vector with a speed of five instead of one? This is easy, too. Simply multiply the one-length vector by five. You'll get a vector pointing in the same direction, but with a length of five instead of one.

O t h e r V e c t o r O p e r a t i o n s

There are quite a few little tricks you can use to get the vector you're looking for. For instance, how the hell would you come up with a vector that points from one object to another? It's simple, really. You just have to know the trick. So, for your reading pleasure, here is the amazing and wonderful chart of useful UnrealScript vector operations.

Normal(Direction):Returns a vector pointing in the same direction as the vector you supply, but with a length of one.

VSize(Direction):Returns a floating point value equal to the length of the vector you supply.

Direction + Direction:Returns a direction vector which is equal to the bisector of the parallelogram formed by the original two direction vectors. What the bloody hell does this mean? Just take a look at the diagram.

As you can see, this is on a 2D plane, and we're talking about 3D space. If you think about it, though, two vectors in 3D space, no matter which direction they're pointing, can always be thought of as being on some 2D plane or another.

Location - Location:Gives you a direction vector which points from the second location to the first, and has a length equal to the distance between the two locations. This is not only useful for making one object move towards another, but also for determining the distance between things.

Location + Direction:Gives you a location equal to the new location an object would have after one unit of time with a velocity of the direction vector. If that made no sense whatsoever to you, think of it this way. Take the X component of the location vector, and add to it the X component of the direction vector. Do the same for the Y and Z components, and you'll end up with the location that's returned by this operation.

Mod Authoring for Unreal Tournament

Introduction

Writing mods for the Unreal engine can be an extremely rewarding task. In the current state of the games industry, there is little better a way for a skilled programmer to show the world what he is capable of. This document is intended to give interested mod authors the information they need to write a successful mod for the Unreal engine. I will include technical information as well as pointers on mod development. If you work hard, you can get some fun stuff done through mod authoring.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]