Project Description

Published On: January 24th, 20230 Comments

GAM 606, Rapid Game Development; Platformer Game

Though this assignment didn’t fare as well as hoped grade-wise, there are parts that I’m still proud of and features of development worth discussing. For starters, I would have probably been better served in trying to create a novel puzzle platformer with basic controls… but I had an image in my mind of a Super Mario Maker-esque level and it was hard to escape that. Because of that insistence, I had to search pretty intensely to find a 2D Platformer Controller for Unity that was tight enough to satisfy my vision but also flexible enough to incorporate the original elements I had in mind.

Some things I just couldn’t crack (like a moving block that can “push” the player horizontally) due to time constraints, so I ended up increasing the complexity and difficulty to compensate. Big mistake! The professor said it felt like I “hated my player” and bailed out before reaching level three. I had made the fundamental error of designing for myself and not my audience: since platformers are such a well-worn genre, I felt there was no point in playing one unless it was a challenge. As I had previously submitted platformers to this professor, I knew there was a high chance I could be the last in a series of games he had to test, and that his reflexes might not be the best by the time my game was up. I insisted on keeping the “purity” of my game intact despite the risks, and learned that lesson the hard way!

Programming Notes

  • Unity Physics can’t seem to handle a perpetually swinging pendulum out of the box, so my solution is to start a coroutine to add back momentum to the pendulum by turning the Motor back on towards the opposite direction briefly when it hits something:
private void OnCollisionEnter2D(Collision2D col)
{
	if (col.gameObject.CompareTag("Ground"))
	{
		StartCoroutine(AddMomentum(.05f));
	}
	else if (col.gameObject.CompareTag("Player"))
	{
		
		var character = col.gameObject.GetComponent<CharacterController2D>();
		if (!character) return;
		
		character.setInvunerable(2);
		
		var player = col.gameObject.GetComponent<PlayerController>();
		if (!player) return;	
		
		player.SoftRespawn();	
		
		StartCoroutine(AddMomentum(.5f));
	}
}
IEnumerator AddMomentum(float length)
{
    hingeJoint2D.useMotor = true;
    var motor = hingeJoint2D.motor;
    motor.motorSpeed = -motor.motorSpeed;
    hingeJoint2D.motor = motor;
    yield return new WaitForSeconds(length);
    hingeJoint2D.useMotor = false;
}
  • When the Pendulum hits the ceiling, it gets a very brief (.05s) spurt of momentum in the opposite direction to ensure that friction doesn’t eventually slow it down to nothing; when it hits the player, it gets a longer (.5s) burst of momentum to ensure it resets properly for the player’s next attempt.

Download/Play

Project Details

Skills Needed:

Categories:

By:

Project Images

DriftDodge
Memory Melee

Leave a Reply

Share This: