x


Aircraft limit movement in trapezoid

Hello,

I'm building a basic flying game, the camera is static and the aircraft is controlled with WASD.

There is no physics bar Rigibody for the bullets and colliders.

The camera is Perspective.

I've used this code to prevent the aircraft moving out of screen;

if ( transform.position.x > PlayerOriginPos.x + MovementLimit )
        {
            transform.position.x = PlayerOriginPos.x + MovementLimit;
        }

        if ( transform.position.x < PlayerOriginPos.x - MovementLimit )
        {
            transform.position.x = PlayerOriginPos.x - MovementLimit;
        }

        if ( transform.position.z > PlayerOriginPos.z + MovementLimitForward )
        {
            transform.position.z = PlayerOriginPos.z + MovementLimitForward;
        }

        if ( transform.position.z < PlayerOriginPos.z - MovementLimitBack )
        {
            transform.position.z = PlayerOriginPos.z - MovementLimitBack;
        }

Though because of the cameras field, i require the area of movement limit to be a upside down trapezoid, i gather it requires math, but i have no idea how to go about this?

Any help would be great, thank you.

more ▼

asked Jan 18 '11 at 11:31 PM

Matthew 5 gravatar image

Matthew 5
32 10 10 12

A suggestion, not a solution: Can you make planes in to a trapazoid, and then just make the player fly in that? Then you can put a kinda enviroment texture on it?

Jan 19 '11 at 12:03 AM Justin Warner
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

You could use the Camera.ViewportToWorldPoint function to set up the bounds for the player.

more ▼

answered Jan 19 '11 at 02:34 AM

cjmarsh gravatar image

cjmarsh
373 2 9

Hello there, thanks for the post, but im not strong enough to understand how that command functions, the unity explaination confuses me

Jan 24 '11 at 04:28 AM Matthew 5
(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

By RSS:

Answers

Answers and Comments

Topics:

x1371
x134
x25
x1

asked: Jan 18 '11 at 11:31 PM

Seen: 930 times

Last Updated: Jan 18 '11 at 11:31 PM