NOTE: This is not a full unity project with scenes and assets, but notes and example scrips
The scrips and steps are based on tutorials from Wireframe Magazine. https://wireframe.raspberrypi.org/issues
Issue 3, Issue 5
The following steps broadly follow the Issue 3 artcle, but with lots fo details missed out.
- Install Unity - https://unity3d.com/get-unity/download
- Create new project, select template 3d.
- Add
Player- Add a 3d object of type capsule
- Rename to
Player - Move
Main CameraintoPlayer - Reset position
Main Cameraso it sits inside player - Set
Main Camerato be higher so it simulats players eyes in head
- Add
Playerbase movement script- In Project window add a
Scriptsdirectory inAssets - Add a script and name it
PlayerMovement. ** Unity expects the class name and file name to match or it goes wonky ** - Double click to open in Visual Studio
- Copy the example
PlayerMovementcode into this new file - Save the script in Visual Studio
- In Unity drag the script onto the
PlayerCapsule - Note the component in the inspector view for the
Playerobject.
- In Project window add a
- Click the play button, escape to exit
- Add
Ground- Add a 3d object of type plane
- Rename it to
Ground - Move it down by changing the Y in inspector
- Make it bigger by changing the X and Y scale in inspector (10 for now)
- Click the play button, escape to exit
- Fixing jump
- Add RigidBody component to the
Player
- Add RigidBody component to the
- Click the play button, escape to exit
- Try jumping and turning at the same time.
- Player may fall over.
- Fix falling over
- In inspector, got to the Rigid Body component, Constraints.
- Check the
Freeze Rotationx and z
- Click the play button, escape to exit
- Try jumping and turning at the same time.
- Player may fall over.
- Add a Cube of type Cube
- Rename in
Wall - Select the scene view
- Use the Gizmo arrows to drag it around
- Use inspector to change the scale and fine tune its possition
- Scale 10, 4, 1
- Position 0, 1, 6
- In Project window add a
Materialsdirectory inAssets - Add new material in here, name it something appropriate
BlueWall - Set the materials color.
- Drag material onto
Wall - Click the play button, escape to exit
- Notice we can't look around using the mouse.
- In the scrpts folder add a new script
- Name it
MouseLook - Double click to open in Visual Studio
4. Copy the example
MouseLookcode into this new file 5. Save the script in Visual Studio 6. In Unity drag the script onto theCameraCapsule - Click the play button, escape to exit
- Notice we can't look around using the mouse.
- Right click the
Playerin Hierachy view and click add Empty Object - Rename it
Weapon - Right click the Hierachy view and click add Empty Object
- Rename it
Projectile - Right click the
Projectilein Hierachy view and click add Capsule Object - Rename it
Bullet - Using inspector rotate the it 90 degrees in the x axis
- Using inspector scale it
.1on x, y and z - Add new material in the materials director, name it something appropriate
RedBullet - Set the materials color.
- Drag material onto
Bullet - In the scrpts folder add a new script
- Name it
ProjectileMovement - Double click to open in Visual Studio
- Copy the example
ProjectileMovementcode into this new file - Save the script in Visual Studio
- In Unity drag the script onto the
Projectileobject
- Copy the example
- In Project window add a
Scriptsdirectory inPrefabs - In the scrpts folder add a new script
- Name it
ActivateProjectile - Double click to open in Visual Studio
- Copy the example
ActivateProjectilecode into this new file - Save the script in Visual Studio
- In Unity drag the script onto the
WeaponObject
- Copy the example