Movement (Week 7)

The player is controlled by the Eight Way Movement script - with additions added to include sprinting in short bursts (set to 0.5 seconds currently). There is a trail renderer on the player to give a sense of motion, the colours and visual style of this will be refined.

Next step was to add a mark to the player sprite so that the player has an indication as to which way they are facing. I simply added a small black rectangle to the player sprite.

I then added a new script so that the player would rotate to face the mouse, which would not affect their movement direction. I found a really handy 'bite-sized' tutorial to achieve this at:

var dir = Input.mousePosition - Camera.main.WorldToScreenPoint(transform.position);
var angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);

(Indie Nuggets, 2018)

Now we have fast and fluid movement, with independent aiming towards the mouse.

Next steps:

  • Introduce the laser mechanics. I have started to implement the ray casting - I just need to connect the ray tracing (with 1 bounce/reflection) into a line renderer that reads the hit points and draws the laser
  • Test out some health mechanics, refining how long it takes for the player to die / get hurt after being hit by the laser
  • Introduce smallest 'grub' enemies, the fast paced but easy to kill variant. This will include spawner behaviour and basic AI to hunt the player (seeking style)


Indie Nuggets, 2018. Unity Nuggets: How to "Look At" Mouse in 2D Game. [video]

[Accessed 17 April 2021]

Leave a comment

Log in with to leave a comment.