H
H
Herman Coffman2019-11-23 14:41:17
C++ / C#
Herman Coffman, 2019-11-23 14:41:17

CrossPlatformInputManager in unity 2018, installation problems. Why?

Hello! In short. using UnityStandardAssets.CrossPlatformInput; there is! But as soon as I write float x = CrossPlatformInputManager.GetAxis("Horizontal"); gives an error like: using directive is missing or there is no assembly reference. Installing the CrossPlatformInput pack fails. In the new version, I did everything the same way: Assets=> import packege but there is no CrossPlatformInput there. Only Custom package... Please explain what's wrong. Can you suggest something similar instead

using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;

public class TrumpCntrl : MonoBehaviour
{

    private Animation anim;
    private Rigidbody rb;
    [SerializeField]
    private float speed = 4f;

    void Start()
    {
        rb = GetComponent<Rigidbody>();
        anim = GetComponent<Animation>();
    }

    void Update()
    {
        float x = CrossPlatformInputManager.GetAxis("Horizontal");
        float y = CrossPlatformInputManager.GetAxis("Vertical");

        Vector3 movement = new Vector3(x, 0, y);
        rb.velocity = movement * speed;

        if (x != 0 && y != 0)
            transform.eulerAngles = new Vector3(transform.eulerAngles.x, Mathf.Atan2(x, y) * Mathf.Rad2Deg, transform.eulerAngles.z);

        if (x != 0 || y != 0)
            anim.Play("Run_New");
        else
            anim.Play("Idle_New");
    }
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Griboks, 2019-11-23
@Griboks

It might be because you are accessing UnityStandardAssets.CrossPlatformInput.CrossPlatformInputManager.GetAxis in your code . Try removing one CrossPlatformInput. CrossPlatformInputManager.GetAxis("Horizontal");

D
Denis Gaydak, 2019-11-23
@MrMureno

I think that the main problem is still in "Install the CrossPlatformInput pack fails"
perhaps the Standard assets are taken from the wrong version and are not imported normally.
maybe in the new version (probably mentioned in the 2018 question, but go guess) - the comrade didn’t figure out where to download them, although it would be worth it just to drive into Google.
There is a strong suspicion, based on the moment
"... I did everything the same way: Assets=> import packege but there is no CrossPlatformInput there ..." - that the author of the question is trying to repeat the actions from the old lessons (two or more years ago).
For versions 2017 and older can be found here https://unity3d.com/en/get-unity/download/archive
For 2017.3, 2018 ,2019 - https://assetstore.unity.com/packages/essentials/a...download in the asset store.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question