Closed Gizmotronn closed 4 years ago
I'm going to finish this video first tho...https://www.youtube.com/watch?v=d09Syw-cij8&t=176s
I mentioned this in the new acord forums: https://allianceofdroids.org.au/portal/groups/science-of-droidology/forum/topic/irisdroidology-manacaster-inscope-me-dev/#post-136
I'm going to make notes on the video and try and complete the rest of the video just following these notes, so that I'm learning more.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// This is an abstract class that all characters needs to inherit from
/// </summary>
public abstract class Character : MonoBehaviour {
/// <summary>
/// The Player's movement speed
/// </summary>
[SerializeField]
private float speed;
private Animator animator;
/// <summary>
/// The Player's direction
/// </summary>
protected Vector2 direction;
// Use this for initialization
void Start () {
animator = GetComponent<Animator>();
}
/// <summary>
/// Update is marked as virtual, so that we can override it in the subclasses
/// </summary>
protected virtual void Update ()
{
Move();
}
/// <summary>
/// Moves the player
/// </summary>
public void Move()
{
//Makes sure that the player moves
transform.Translate(direction * speed * Time.deltaTime);
if (direction.x != 0 || direction.y != 0) // If the x-direction or y-direction of the game object (e.g player) is not 0, then go to next line and follow instructions ## If it is not 0, the object is moving in some way!
{
//Animate's the Player's movement
AnimateMovement(direction);
}
else // if the object is NOT moving ## object/game-object
{
{
animator.SetLayerWeight(1, 0); // Set back to the idle layer
}
}
}
/// <summary>
/// Makes the player animate in the correct direction
/// </summary>
/// <param name="direction"></param>
public void AnimateMovement(Vector2 direction)
{
animator.SetLayerWeight(1,1); // # inscope.me 1.3 ## Sets the second animator layer (walk_layer - index values python) to the active layer when the key input to walk is found
//Sets the animation parameter so that he faces the correct direction
animator.SetFloat("x", direction.x);
animator.SetFloat("y", direction.y);
}
}
1. If Player is moving:
if direction.x = 0 || direction.y != 0 { // if x is different from 0 & y is different from 0 (i.e. the player is moving in a direction):
// Animate player movement
AnimateMovement(direction);
}
2. When player finishes moving:
else // if the object is NOT moving ## object/game-object
{
{
animator.SetLayerWeight(1, 0); // Set back to the idle layer
}
}
Setting the animator to show different walk anims (for example, "Walk_Up") for player game object: This is set-up from 1.2 tutorial inscope.me RPG!!
Commit: https://github.com/IrisDroidology/manacaster/commit/507fee95397797c699b2780b963c48ec2a87e011
Referring to https://github.com/IrisDroidology/manacaster/tree/inscope-2.0
Need to watch through inscope-rpg-1.3? again...
Everything else is working fine thanks to inscope.me