Open warasadi opened 1 year ago
using UnityEngine;
public class CubeMovement : MonoBehaviour { public float moveSpeed = 5.0f;
void Update()
{
float horizontalInput = Input.GetAxis("Horizontal");
float verticalInput = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(horizontalInput, 0.0f, verticalInput) * moveSpeed * Time.deltaTime;
transform.Translate(movement);
// Batasi pergerakan kubus agar tidak keluar dari batas tertentu
float xBound = 5.0f; // Gantilah dengan batas sesuai kebutuhan
float zBound = 5.0f; // Gantilah dengan batas sesuai kebutuhan
Vector3 currentPosition = transform.position;
currentPosition.x = Mathf.Clamp(currentPosition.x, -xBound, xBound);
currentPosition.z = Mathf.Clamp(currentPosition.z, -zBound, zBound);
transform.position = currentPosition;
}
}
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class putar : MonoBehaviour { public float rotationSpeed = 100.0f; // Kecepatan putaran koin (sesuaikan sesuai kebutuhan)
}