edited July 27 in ORK Support
My goal is to make a First/Third person rpg kind of game, kinda like The Elder Scrolls/Fallout but much more Story Driven like old Jrpgs, and with Real Time battle system (like Shooter if possible). For the moment I am focusing on the First Person mode (Later on I will have to figure out How to change between first/third person view) So I've been setting up a First Person controller using a premade free script that i found on the internet, named "SC_FPS CONTROLLER", succesfully set up basic LEGACY animations (I want the player is able to see his own body and shadow in First Person mode).

The problem is: As long as my character walks/runs over plain terrain everything is fine. As soon as it walks on a slope, no matter how steep it is, It starts to switch very quickly and continuously between Falling/Running or Walking animations. I've been looking around the internet for answers, and found something about Ground Checking, but it seems the script that i am using already has that function set up correctly. I've been tortured by this issue for days, tried so many solutions (deleting animations, modifying gravity values and animation cross fading settings) Nothing worked. Later on i will post a video to show you better what i mean (will take a while, I live in a place where Internet Connection is horribly low). In the meantime I hope i've already given you at least a trace of what my problem could be. Thanks you in advice, your help, or any other advice about what I am trying to achieve would be so much appreciated.
Post edited by Framan on
  • here is the First Person Script that i am using:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    [RequireComponent(typeof(CharacterController))]

    public class SC_FPSController : MonoBehaviour
    {
    public float walkingSpeed = 7.5f;
    public float runningSpeed = 11.5f;
    public float jumpSpeed = 5;
    public float superjump = 12;
    public float gravity = 20.0f;
    public Camera playerCamera;
    public float lookSpeed = 2.0f;
    public float lookXLimit = 45.0f;

    CharacterController characterController;
    Vector3 moveDirection = Vector3.zero;
    float rotationX = 0;

    [HideInInspector]
    public bool canMove = true;

    void Start()
    {
    characterController = GetComponent();

    // Lock cursor
    Cursor.lockState = CursorLockMode.Locked;
    Cursor.visible = false;
    }

    void Update()
    {
    // We are grounded, so recalculate move direction based on axes
    Vector3 forward = transform.TransformDirection(Vector3.forward);
    Vector3 right = transform.TransformDirection(Vector3.right);
    // Press Left Shift to run
    bool isRunning = Input.GetKey(KeyCode.LeftShift);
    float curSpeedX = canMove ? (isRunning ? runningSpeed : walkingSpeed) * Input.GetAxis("Vertical") : 0;
    float curSpeedY = canMove ? (isRunning ? runningSpeed : walkingSpeed) * Input.GetAxis("Horizontal") : 0;
    float movementDirectionY = moveDirection.y;
    moveDirection = (forward * curSpeedX) + (right * curSpeedY);

    /*Valentina 20/05/2020 - per poter ricevere l'input controllo che canMove sia vero
    e che il personaggio sia a terra (?)
    */
    //TODO test
    if (canMove && characterController.isGrounded)
    {
    //se sono veri (premuti) entrambi i pulsanti, effettuo il superjump,
    //altrimenti se è premuto solo il pulsante di salto effettuo il salto normale
    if (Input.GetButton("Jump") && Input.GetButton("Run"))
    {
    moveDirection.y = superjump;
    }
    else if (Input.GetButton("Jump"))
    {
    moveDirection.y = jumpSpeed;
    }
    }
    else
    {
    moveDirection.y = movementDirectionY;
    }

    // Apply gravity. Gravity is multiplied by deltaTime twice (once here, and once below
    // when the moveDirection is multiplied by deltaTime). This is because gravity should be applied
    // as an acceleration (ms^-2)
    if (!characterController.isGrounded)
    {
    moveDirection.y -= gravity * Time.deltaTime;
    }

    // Move the controller
    characterController.Move(moveDirection * Time.deltaTime);

    // Player and Camera rotation
    if (canMove)
    {
    rotationX += -Input.GetAxis("Mouse Y") * lookSpeed;
    rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit);
    playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0);
    transform.rotation *= Quaternion.Euler(0, Input.GetAxis("Mouse X") * lookSpeed, 0);
    }
    }
    }
  • Well, what's responsible for playing the animation?
    E.g. are you using ORK's auto animation setup?
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • I have assigned my animations to the Ork framework Animations section (Legacy), and also in the Animation component of my character prefab. So i'd say it is Ork? Not sure about this Auto Animation setup?
  • The auto animations are set up in your combatant's settings (pretty much at the bottom of them) and automatically play idle/walk/run/sprint animations depending on the combatant's movement speed.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Wow It seems that solved my problem. I found at the very bottom of the combatant settings the "Find Ground" section, turned on "Own Find Ground" and set "On Ground Check" to Raycast. Works very good now. Thank you!
  • Ah, yeah - there's a default Find Ground setting for all combatants available in Battle System > Battle Settings > Combatant Settings.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.