Search Unity

AR core problem in movement of the object while animating(Need Urgent Help!)

Discussion in 'AR' started by Doomguy16, Aug 28, 2019.

  1. Doomguy16

    Doomguy16

    Joined:
    Jul 30, 2019
    Posts:
    2
    So I have been working on a project where I am making an zoo tycoon like game in AR.I have imported few assets from unity asset store (A tiger for now).Now I wanted the Tiger to move around when clicked first I coded a very basic translation code for straight line movement only.It was successful than I watched a tutorial on movement + animation but when I add animation to it the tiger does not move when placed in AR world and only first animation plays here is the code I made:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class just : MonoBehaviour
    {
    Animator anim;
    public float timer; //feeding timer value from inspector
    private bool isWalking = false;
    private float speedTiger = 0.2f;
    private float rotSpeed = 75.0f;
    // Start is called before the first frame update
    void Start()
    {
    anim = this.gameObject.GetComponent<Animator>();
    }
    // Update is called once per frame
    void Update()
    {
    if (!isWalking) //if tiger is not walking than playing the walking animition
    {
    anim.SetBool("walk", true);
    isWalking = true;
    }
    //translation in the forward direction
    this.gameObject.transform.Translate(Vector3.forward * speedTiger * Time.deltaTime);

    if (timer < 0) //when timer == 0 than stop the motion
    {
    speedTiger = 0;
    anim.SetBool("walk", false); //setting animaiton to idle animaiton
    }

    timer -= 1/50;

    //this.transform.Translate(Vector3.forward * speedTiger * Time.deltaTime);
    }
    }