2danim-demo
2danim-demo
Krampus Demo
15 posts
Don't wanna be here? Send us removal request.
2danim-demo · 1 year ago
Text
0 notes
2danim-demo · 1 year ago
Text
The Code I ended up using:
using UnityEngine;
public class PlayerController : MonoBehaviour
{
private Animator animator;
private Rigidbody2D rb;
public float speed = 5f;
public float jumpForce = 10f;
private bool isGrounded;
private bool isWalking;
private bool isRunning;
private void Start()
{
animator = GetComponent<Animator>();
rb = GetComponent<Rigidbody2D>();
}
private void Update()
{
// Handle input for movement
float horizontalInput = Input.GetAxis("Horizontal");
isWalking = Mathf.Abs(horizontalInput) > 0.1f;
isRunning = Input.GetKey(KeyCode.LeftShift);
// Set animator parameters based on input
animator.SetBool("Idle", !isWalking);
animator.SetBool("Walk", isWalking && !isRunning);
animator.SetBool("Run", isWalking && isRunning);
// Jumping
if (Input.GetButtonDown("Jump") && isGrounded)
{
animator.SetTrigger("Jump");
rb.AddForce(new Vector2(0f, jumpForce), ForceMode2D.Impulse);
}
// Special move
if (Input.GetButtonDown("SpecialMove"))
{
animator.SetTrigger("SpecialMove");
// Add code for special move behavior here
}
}
private void FixedUpdate()
{
// Check if the player is grounded
isGrounded = Physics2D.OverlapCircle(transform.position, 0.2f, LayerMask.GetMask("Ground"));
}
}
This ended up being my final code, however it was not working because it turns out I didn’t have a movement script included. In Unity, I created completely new parameters from scratch, so I could start over. I added isWalking, isRunning and isGrounded bool parameters, and set Jump and SpecialMove as triggers. Jump was already there, but I created a custom SpecialMove key in Unity Editor. I’m using A & D movement, space to jump and E for special move
0 notes
2danim-demo · 1 year ago
Text
Failed Experiment #3 Blend Trees
I was reluctant to use a blend tree since I’m using frame by frame animation. I didn’t want the transition between my frames to look weird and jittery, but I thought using a blend tree would allow me to have multiple animations accessible from the same node. I kept getting compiler errors with the code so I abandoned this.
Tumblr media
0 notes
2danim-demo · 1 year ago
Text
Failed Experiment #2: following an online tutorial for the code
I found a 2D platformer tutorial on YouTube. I found some small success, because I was able to make left and right movement. I locked Z rotation so my player wouldn’t fall on his face, and managed to code the sprite to flip. I coded in the jump movement, but I could not figure out creating a state for jump animation. Either way, if I had continued to use this code, I would not have been able to make a special move.
Tumblr media
0 notes
2danim-demo · 1 year ago
Text
Failed Experiment #1. Using the Given Script
I attached the script provided to my player, at first I barely managed to move it, and I had a very delayed jump. I could not activate the special move at all. I did not use this code, however I realize in hindsight part of why it might not have worked is I did not have a SpecialMove element created in my Unity Editor
Tumblr media
0 notes
2danim-demo · 1 year ago
Text
Tumblr media
I made a pixelated version of the background in my original animation to act as my background. I created a box collider from the bottom until where I wanted the player to stand.
0 notes
2danim-demo · 1 year ago
Text
Tumblr media
For Unity, I created a massive sprite sheet with all animations. That way, I’m able to pick specific frames for each of the animations in the Animation window for the player, without taking up space on my laptop by having each animation on an individual sprite sheet
0 notes
2danim-demo · 1 year ago
Text
Here is a Timelapse of how I made the special move Animation
0 notes
2danim-demo · 1 year ago
Text
Here is the Special Move. For this one, I had to make some new angles and I made an asset for the bell
0 notes
2danim-demo · 1 year ago
Text
Here is the jump. I originally planned to have two jumps but found that the run to jump worked well from Idle too
0 notes
2danim-demo · 1 year ago
Text
Here is the running animation
0 notes
2danim-demo · 1 year ago
Text
This is the Walking Animation
0 notes
2danim-demo · 1 year ago
Text
The Idle Animation is a simple bobbing up and down
0 notes
2danim-demo · 1 year ago
Text
As you can see, I have multiple movements with one angle, so if I needed to recycle any animation components, I always had a layer copy to use. For most of the frames, I only had to sketch the leg movement since the body was already there
Tumblr media
0 notes
2danim-demo · 1 year ago
Text
Ok so first of all I decided I wanted to use pixel art for this task. It’s much easier overall to animate with as I don’t have to worry about
1. Blurring/Pixelation issues during transformation
2. Awkward cropping
3. Having to take time to completely render every frame
I can split parts of the body much easier for faster animation. First I picked a frame from my original animation and scaled it down using Nearest Neighbor transformation. That way it’s already pixelated
Tumblr media Tumblr media
0 notes