Unable to call UnityStandardAssets.CrossPlatformInput

Hi guys,

I’m currently building TileVania using Unity 2019.3.12 with VS community 2019. I’ve download and imported the Standard Assets from the Asset Store. However, when I tried to call it in VS via “using UnityStandardAssets.CrossPlatformInput” VS gives me a warning that the CrossPlatformInput namespace does not exist in the namespace UnityStandardAssest. How can I get around it to solve this?

In addition, I saw in one of the comments in udemy, someone had got around this by using Input.GetAxis(“Horizontal”) instead of CrossPlatformInputManager.GetAxis(“Horizontal”). However, when I tried the same approach, it kinda works. But my character, instead of walking horizontally, it kinda rotates across the platforms like it is doing cartwheels instead. I’ve used the exact same as shown in the video, except where Rick uses CrossPlatformInputManager.GetAxis(“Horizontal”), I changed it to Input.GetAxis(“Horizontal”). Can anyone give me a heads up, as to where I did wrong in this part as well?

thanks

CrossPlatformInput is outdated Input is the newest built in. As for the rotating problem… Are you using a rigidbody? Maybe you missed one step? What does your code look like?

Hi Riley,

the code I use are as follows

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


public class Player : MonoBehaviour
{
    [SerializeField] float runSpeed = 5f;
    Rigidbody2D myRigidBody;

    // Start is called before the first frame update
    void Start()
    {
        myRigidBody = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        Run();
    }

    private void Run()
    {
        float controlThrow = Input.GetAxis("Horizontal"); // value is between -1 to 1
        //velocity in x and y direction is group together using a 2d Vector called playerVelocity where,
        //x direction velocity is obtain via a (float) variable called controlThrow which called Input.GetAxis("Horizontal")
        //while y direction velocity is set using current y velocity of the character
        Vector2 playerVelocity = new Vector2(controlThrow * runSpeed, myRigidBody.velocity.y);

        //velocity for the character rigid body is set using the playerVelocity vector
        myRigidBody.velocity = playerVelocity;
    }
}

and here’s a clip on what i meant

Try turning on the freeze rotation restraint in your rigidbody

hi riley,

you’re absolutely right! I did remembered Rick saying that in the video, but somehow I forgot to do it. thanks!

No problem! Glad it’s working now!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms