Hello !
I want to make a pendulum movement on a spherical character.
But with my code the movement is blocking in the left or on the right when I go forward or backward.
Could you help me ?
using UnityEngine;
using System.Collections;
[System.Serializable]
public class Boundary{
public float xMin, xMax, yMin, yMax;
}
public class toController : MonoBehaviour {
private Rigidbody rb;
public float speed;
public Boundary boundary;
public float titlt;
private float rot;
private int xcoord;
void Start ()
{
rb = GetComponent<Rigidbody>();
}
void Update()
{
xcoord = Mathf.FloorToInt(Input.GetAxis ("Horizontal"));
if (xcoord % 10 == 0) {
rot = -1;
}
else
{
rot = 1;
}
rb.rotation = Quaternion.Euler (0,90,rb.velocity.x * titlt * rot);
}
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rb.velocity = (movement*speed);
}
}