i want to ball move inside pipe like hollow cylinder.Ball constantly moving forward and by arrows we can move ball 180 degree left or in curved path right like
picture.i write that can move ball in curved shape but i can’t able to move forward constantly.help me
currentRotation += Input.GetAxis("Horizontal")*Time.deltaTime*200;
currentRotation=Mathf.Clamp (currentRotation, -180, 0);
rotation.eulerAngles = new Vector3(0,0, currentRotation);
print (rotation * radius);
transform.position = rotation*radius ;
hi, can be done with Rigidbody.AddForce like this :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class moveball : MonoBehaviour {
public float speed=2.0f;
void FixedUpdate()
{
float moveHorizontal = Input.GetAxis( "Horizontal" );
float moveVertical = Input.GetAxis( "Vertical" );
Vector3 movement = new Vector3( moveHorizontal , 0.0f , moveVertical );
GetComponent<Rigidbody>().AddForce( movement * speed * Time.deltaTime );
}
}