x


thruster-like 2d movement

I want to make a simple game with Spore-like movement for my player character (first stage, "cell"). For thosue unfamiliar with that game, it's in complete 2D, user point and click direction he want to move, then character model rotate its "front" to that point and then follow the pointer until mouse button is released. Two major questions here are: 1) how can I make usual physics stick to 2D in all movement, collisions, etc; 2) how can I make smooth rotation and movement (with a bit of inertia). I'm quite new to Unity, so few examples of scripting something similar would be excellent. I've tried to modify standart DragRigidbody script to my needs, but I feel that it's not exactly right for this purpose, but maybe joints are what I need. JavaScript and C# are both welcome.

more ▼

asked Apr 18 '10 at 11:57 AM

Tixed gravatar image

Tixed
1 1 1 1

Looks like a lot of questions here. You should split them up into individual posts to make searching and referencing easier.

Apr 18 '10 at 12:12 PM spinaljack
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

1)You can add a plane or terrain across the scene and have the camera look down the y-axis, gravity should keep everything on the same level, you might also try putting an invisible collider across the top of everything to form a low ceiling maybe. Putting the camera into orthographic view makes for a 2D effect.

Better yet use a configurable joint to restrict movement in one of the planes and your objects will always be in 2D movement.

2)If you are using the built in physics engine then you can use the drag variable of the rigid body for inertia, angular drag also slows down spinning motions. Use rigidbody.addforce for thruster like movement. There's an add torque function as well but it's easier just the manipulate the rotation directly.

Here's a 2D game tutorial complete with assets

more ▼

answered Apr 18 '10 at 12:20 PM

spinaljack gravatar image

spinaljack
9.1k 18 31 91

(comments are locked)
10|3000 characters needed characters left

Whenever I'm making a Rigidbody that's supposed to operate is 2D I just go into the Rigidbody's constraint tab and click on Y in "freeze Position" then X and Z in "freeze Rotation"

This stops the object from moving up and down plus halts rotation coming off the plane. If it's not a Rigidbody then you can just set position.y = some fixed value and rotation = fixed except yrotation

more ▼

answered Jul 17 '12 at 01:42 AM

Muuskii gravatar image

Muuskii
1.1k 4 10

(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:

x1881
x1373
x1041

asked: Apr 18 '10 at 11:57 AM

Seen: 2447 times

Last Updated: Jul 17 '12 at 01:42 AM