Player Controller PART 2: How To Make Player Move (Tutorial)

preview_player
Показать описание
This is the second part of our character controller tutorial.

In this video you'll learn how to make our player move, and how to switch between idle and walk Spine animations.

Hope you'll find it useful! 👍

As always, Russian titles available!
Субтитры на русском! 😉

Here's the link to the official Spine Unity Runtime documentation:

_______________________

FOLLOW US

►Instagram:

►Twitter:

_______________________

MUSIC

Creative Commons — Attribution 3.0 Unported— CC BY 3.0

#spine2d #unity2d #charactercontroller #unitytutorial #madewithunity #madewithspine #spineanimation #skeletonanimation #tutorial #howto #thinkcitric #gamedev #gamedevelopment #unity2019 #playercontroller
Рекомендации по теме
Комментарии
Автор

Hey guys! There is a small issue that was brought up to me: if you set a different scale for your character in the Inspector, the controller script will set it back to 1.
So, if you have this issue with scaling, here's what you can do:

1. Declare a new variable: private Vector3 characterScale;
It will store the scale that you've configured in the editor.



2. In the Start method, let's set this new vector to this: characterScale = transform.localScale;
So that at the start of each scene, the actual scale of the character is stored in this variable.



3. In the Move method, let's change the if(movement > 0) condition. Currently, it is
if (movement > 0)
{
transform.localScale = new Vector2(1f, 1f);
}
else
{
transform.localScale = new Vector2(-1f, 1f);
}

But it should be:

if (movement > 0)
{
transform.localScale = new Vector2(characterScale.x, characterScale.y);
}
else
{
transform.localScale = new Vector2(-characterScale.x, characterScale.y);
}

This will turn the character in accordance with the movement direction, and keep the scale that you've set in the Inspector.
Hope it helps!

ThinkCitric
Автор

Hey, thanks for watching! 🧡

Part 3 of this tutorial will be available by the end of the next week.
Please feel free to ask me any questions!

ThinkCitric
Автор

this tutorial is amazing! perfect intro to how to manipulate spine animations with code. thanks so much for making this!

kpickett
Автор

Great Tutorial, excellent pacing, all the details and on top soothing voice. Thanks for making these!

Chilzivi
Автор

Your video is awesome, i wonder why it has so little likes, keep up your works

vietanhnguyen
Автор

Since many of you have asked, I've created a few Udemy courses on Spine! 💛
► Spine Essential course:
► Spine Pro course:

ThinkCitric
Автор

Hi I was wondering, can you layer animations like in the unity animator or no?

stuff
Автор

Hi I created individual spine projects for different actions of one game character. I wonder if i need to merge them and create only one atlas file.

谭嘉禛
Автор

Can you explain how you got Player with Skeleton Mesh, Skeleton animation, Box Collider 2D and Rigibody?

artofdpen
Автор

Hi! Thanks so much for the tutorial!
What to do if we need to add a new animation to the character?

kojirohiori
Автор

great tutorial but i have one error, please help me. This is error: Assets\Scripts\Player_Controller.cs(28, 49): error CS1503: Argument 2: cannot convert from 'UnityEngine.AnimationState' to 'string'

DannyOnateArt
Автор

Hello! Lovely tutorials, thank you so much!

My character seems to automatically start walking to the left (and falling over) as soon as I hit Play. The falling has been solved by adding a Freeze Rotation constraint, but nothing seems to stop it from automatically walking off. What am I doing wrong here? I've applied the scale fix mentioned in the comments.

public void Move()
{
movement = Input.GetAxis("Horizontal");
rigidbody.velocity = new Vector2(movement * speed, rigidbody.velocity.y);
if (movement != 0)
{
SetCharacterState("Walking");
if (movement > 0)
{
transform.localScale = new Vector2(characterScale.x, characterScale.y);
}
else
{
transform.localScale = new Vector2(-characterScale.x, characterScale.y);
}

yellerdog
Автор

Hello, excellent tutorials, I hope you can do more about spine and unity. I wanted to ask you if it is possible to use cinemachine with spine skeleton, so that the camera follows the character. Thanks and regards from Argentina.

darken
Автор

H, thank you for your great tutorial. This has helped me a lot with th e project I'm working on. As I'm trying to ass more and more animations, some of them won't work. I noticed that the CurrentState in the Inspector is ALWAYS set to "Idle". Other animations like "Reloading" or "sliding" hence don't work. Do you have any tips for me ? Thanks a lot !

sarahtonpere
Автор

Hey! I am trying to get this done as well. Since I had no background in animation, I have outsourced the actual animations and now trying to get them into Unity... I have a peculiar environment, though - it's 3D, but the character is in 2D. Built as a platformer, though. Would you be available for couple rarely specific questions? :)

oainsh
Автор

Hi thank you so much for the tutorials, I just started learning unity.
i have a small programming background and i' wanna be an indie Developer (solo if possible).
i started a C# course to refresh what i knew and also learn Unity Classes/Methods and all that stuff.
problem is when i watched your tutorial and other people's videos online i got super overwhelmed with all the things i need to learn.
and also the order of learning these things.
currently as i said i'm focusing on C#, but i don't know what to do next.
so please give me some advice thank you.

mikegameartist
Автор

Problem, my animations do not want to switch even after making sure that the names are correct, any suggestions?

exmarxgames
Автор

how can i scale the Animation? if i scale the Player, the Animation is x1/y1.

miloweigel