Ellen

Checked with version: 2017.3

-

Difficulty: Beginner

The Ellen Prefab is the Player character for the Game Kit. Aside from the standard platform controls of moving and jumping she can crouch, jump down (through platforms), melee attack and shoot.

Standard movement controls (PC)

Move A, D
Jump Space
Crouch S
Shoot O
Melee K
Activate E
Pass Through Platform S and Space

She is put together using Sprite Renderer , Animator , Capsule Collider 2D and Rigidbody 2D components as well as a number of custom scripts.

Character Controller 2D

The Character Controller 2D script is used to move Ellen within the Scene while obeying physics.

  • Grounded Layer Mask: Default Setting: Platform These are the layers which the character can stand on. Having it set to the Platform layer allows Ellen to walk on anything else that is on that layer such as the ground.

  • Grounded Raycast Distance: Default Setting: 0.1 This determines whether Ellen is standing on the ground by using Raycasts from the bottom of her Collider. Increasing this number would make Ellen think the ground is higher and her feet would get stuck in the platform. Lowering this number will make Ellen think the ground is lower causing her to look like she is falling.

Player Input

In this project you can easily remap the input for a player. The Player Input script tells Unity’s Input Manager what controls your game should use. Whether it’s keyboard and mouse or an Xbox One controller, you can change the keys or buttons for your game on this component.

Please note that any changes to this component are per Scene, as you are changing the copy (instance) of the Ellen Prefab. If you have multiple levels in your game and you have changed Ellen’s Player Input, you must hit the Apply button at the top of the Ellen instance. This changes the settings on the original Prefab and ensures that any other instance of Ellen in other levels have the same input.

We’ve provided a handy reminder to let you know if you’re looking at an instance. If you see this warning on the Player Input component, click Select Prefab, which takes you to edit the prefab.

The settings for Player Input are;

  • Input Type: Default Setting: Mouse And Keyboard. The option for the type of input, the options are Mouse and Keyboard or Controller. The default controller type for this Kit is Xbox One.

  • Pause: The key press or button used for pausing the game.

    • Key: The key on the Keyboard pressed for the action.

    • Controller Button: The controller button pressed for the action.

    • Enabled: Whether the action is on or off. Ticked is on, unticked is off.

  • Interact: The key press or button used for interacting with the environment.

    • Key: The key on the Keyboard pressed for the action.

    • Controller Button: The controller button pressed for the action.

    • Enabled: Whether the action is on or off. Ticked is on, unticked is off.

  • Melee Attack: The key press or button used for Ellen swinging her Staff.

    • Key: The key on the Keyboard pressed for the action.

    • Controller Button: The controller button pressed for the action.

    • Enabled: Whether the action is on or off. Ticked is on, unticked is off.

  • Ranged Attack: The key press or button used for Ellen shooting her gun.

    • Key: The key on the Keyboard pressed for the action.

    • Controller Button: The controller button pressed for the action.

    • Enabled: Whether the action is on or off. Ticked is on, unticked is off.

  • Jump: The key press or button used for jumping.

    • Key: The key on the Keyboard pressed for the action.

    • Controller Button: The controller button pressed for the action.

    • Enabled: Whether the action is on or off. Ticked is on, unticked is off.

  • Horizontal: The key press or analogue stick to move left or right.

    • Positive: The key on the keyboard to move the character right (positive on the X axis).

    • Negative: The key on the keyboard to move the character left (negative on the X axis).

    • Controller Axis: The controller analogue stick or button to move left and right.

  • Vertical: The key press or analogue stick to crouch or look up.

    • Positive: The key on the keyboard to move the camera to look up (positive on the Y axis).

    • Negative: The key on the keyboard to crouch (negative on the Y axis).

    • Controller Axis: The controller analogue stick or button to look up and crouch.

  • Persistence Type and Data Tag: For information on how the Data Persistence system works see the Data Persistence section. Whether Melee Attack and Ranged Attack are enabled is the data persisted by this class.

Player Character

The Player Character script holds all the information for how Ellen behaves in the game, the settings here affect movement, Audio and Cameras.

If you change any settings, the changes are only applied to the Prefab instance in that Scene. If you would like the changes to happen across all levels in your game, click Apply at the top of the instance for the change to be applied to the Ellen Prefab.

  • References: By default you should not need to adjust this.These are all the references the script requires to function.

    • Sprite Renderer: Used to determine which way the character is facing.

    • Damageable: Used to determine the direction of motion when the character is hurt.

    • Melee Damager: Used to enable/disable damage during appropriate animations.

    • Facing Left/Right Bullet Spawn Point: Used as locations to spawn bullets from when firing.

    • Bullet Pool: Used when spawning bullets.

    • Camera Follow Target: Used to control camera positioning relative to the character, which allows behaviour such as maintaining a lead from the character when moving fast.

  • Movement Settings: These are the settings for controlling how fast Ellen moves on the ground.

    • Max Speed: Default Setting: 7 How fast Ellen can run.

    • Ground Acceleration: Default Setting: 100 How fast Ellen gets to her Max Speed when on the ground.

    • Ground Deceleration: Default Setting: 100 How fast Ellen slows to a stop when there is no input.

    • Pushing Speed Proportion: Default Setting: 0.5 What proportion of the Max Speed Ellen moves at when pushing a box.

  • Airborne Settings: These are the settings for controlling how fast Ellen moves while in the air.

    • Airborne Accel Proportion: Default Setting: 1 What proportion of the Ground Acceleration Ellen uses when in the air.

    • Airborne Decel Proportion: Default Setting: 0.5 What proportion of the Ground Deceleration Ellen uses when in the air.

    • Gravity: Default Setting: 38 How fast Ellen accelerates towards the ground. This also affects the jump height.

    • Jump Speed: Default Setting: 16.5 How fast Ellen takes off from a jump. This affects the jump height.

    • Jump Abort Speed Reduction: *Default Setting: 100 *The speed at which the jump value is reduced when the jump button is released. This affects jump height.

  • Hurt Settings: These settings determine how Ellen moves and appears when she is hurt. For other settings to do with how Ellen reacts to damage see the section of this document on the Damage System.

    • Hurt Jump Angle: Default Setting: 45 When Ellen is hurt she recoils by jumping into the air away from the source of the damage. This is the angle from horizontal at which she jumps.

    • Hurt Jump Speed: Default Setting: 8 How fast Ellen takes off when recoiling from damage.

    • Flickering Duration: Default Setting: 0.05 When Ellen is hurt her sprite turns on and off quickly to produce a flickering effect. This duration sets how long the sprite stays on and off whilst flickering.

  • Melee Settings: These are settings for how Ellen moves when she swings her staff. For other settings to do with how Ellen damages things see the section of this document on the Damage System.

    • Melee Attack Dash Speed: Default Setting: 15 The distance at which Ellen dashes horizontally when she attacks with a Staff.

    • Dash While Airborne: Default Setting: Enabled An optional setting to enable a dash during an airborne attack. This sets horizontal movement and does not increment it. If Ellen is already moving horizontally while airborne, this setting may not be noticeable.

  • Ranged Settings: These are settings to do with the bullets that are spawned when Ellen is firing her gun.

    • Shots Per Second: Default Setting: 2 The maximum number of bullets that can be spawned per second.

    • Bullet Speed: Default Setting: 30 The speed given to bullets when they are spawned.

    • Holding Gun Timeout Duration: Default Setting: 1.5 How long Ellen continues to hold her gun out after she has stopped firing.

    • Right Bullet Spawn Point Animated: Default Setting: Enabled The bullet spawn point is animated to follow the gun position. By default, the Ellen asset has a bullet spawn position on the right. When she is facing left we mirror the spawn point animation. If you would like to add your own animated sprite that faces to the left, then uncheck this box.

  • Audio Settings: By default you should not need to adjust this. We randomise the audio played for Ellen’s various actions so that it does not sound repetitive. These are the references to the RandomAudioPlayers which play the audio.

    • Footstep Audio Player: The RandomAudioPlayer used when Ellen makes a step.

    • Landing Audio Player: The RandomAudioPlayer used when Ellen becomes grounded after being airborne.

    • Hurt Audio Player: The RandomAudioPlayer used when Ellen is damaged.

    • Melee Audio Player: The RandomAudioPlayer used when Ellen does a melee attack.

    • Ranged Attack Audio Player: The RandomAudioPlayer used when Ellen does a ranged attack.

  • Camera Follow Settings: Rather than following Ellen, the camera follows a target offset from Ellen’s location. These settings control the offset.

    • Camera Horizontal Facing Offset: Default Setting: 2 The amount the target is offset horizontally in front of Ellen.

    • Camera Horizontal Speed Offset: Default Setting: 0.2 The amount the target is shifted based on Ellen’s horizontal speed.

    • Camera Vertical Input Offset: Default Setting: 2 How much the target is offset vertically based on the player’s input.

    • Max Horizontal Delta Damp Time: Default Setting: 0.4 The amount of time it takes for the target to move horizontally from no offset to its desired horizontal offset.

    • Max Vertical Delta Damp Time: Default Setting: 0.6 The amount of time it takes for the target to move vertically from no offset to its desired vertical offset.

    • Vertical Camera Offset Delay: Default Setting: 1 The amount of time that the up or down input keys need to be held before the target starts to move vertically, so that the player can ‘look up’ or ‘down’.

  • Misc Settings: A folder for other settings.

    • Sprite Originally Faces Left: Default Setting: Disabled This refers to the sprite asset itself without any flipping. It is used to determine things like which spawn point bullets should spawn from.

Related tutorials