Hello I apologize for my bad English.
Can you help me for a few days I test a lot of codes and nothing works properly.
I’m doing 2D games, and I liked this character. Aj
https://www.mixamo.com/#/?page=1&type=Character
but I can not find a working code for the player’s movement “left right and jump”
Can anyone help me with the code for movement.
I found this code, only the character animations work with him, but it only moves to the right.
If someone knows how to edit this code to move the profile to the left and to jump
#pragma strict
internal var animator : Animator;
var v : float;
var sprint : float;
function Start ()
{
animator = GetComponent(Animator);
} function Update ()
{
v = Input.GetAxis("Horizontal");
Sprinting();
}
function FixedUpdate ()
{
animator.SetFloat("Speed", v);
animator.SetFloat("Sprint", sprint);
}
function Sprinting () {
if(Input.GetKey(KeyCode.LeftShift))
{
sprint = 1;
}
else
{
sprint = 0;
}
}
You are just starting, and I would advise you to begin searching for tutorials written in C#.
Use C# only for your own scripts, as Unity script (what your post is written in), is being deprecated in Unity.
https://unity3d.com/learn/tutorials
Hi
The script looks familiar although I have mostly worked with 3D animation.
Some things to check.
- Is there an animation controller added to your character?
- Is there a player script attached to your player?
- Is your Animation controller configured correctly. Are there animations added?
With 3D animated characters one generally needs to rig their character so that it can be retargeted with animations from another character. Iam not sure if this is the case with 2D animation.
I will also recommend to start from scratch. Throw aside all other people examples and focus on basics. Like learning how to translate and rotate gameobjects from code with input from the keyboard, mouse or even a joystick.
If you still stuck just post a reply.
This.
It’s better to learn these simple things instead of copying someones code that you don’t understand. It would be a good learning experience.