i want my object stick with land but i haven't got luck my land anyone help?,i want to move object stuck with land but i haven't got luck anyone help me
this is my moving script
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Anhaa : MonoBehaviour { public Transform player; public Rigidbody rb; //public MoveLeft move; [SerializeField] public float speed = 2000f; // Use this for initialization void Start () { rb = player.GetComponent(); }
// Update is called once per frame
void Update () {
forward();
Vector3 mousePos = Input.mousePosition;
if(Input.GetMouseButton(0))
{
if(mousePos.x >450)
{
turnleft();
}
else if(mousePos.x<450)
{
turnright();
}
Debug.Log(mousePos.x); } } public void forward(){ transform.Translate(new Vector3(0, -5 Time.deltaTime,10 Time.deltaTime)); } public void turnleft(){ rb.AddForce(Vector3.right *speed); } public void turnright(){ rb.AddForce(Vector3.left *speed); }
} ,
untitled.png
(360.6 kB)
Comment