using UnityEngine;
using System.Collections;
public class BallControl : MonoBehaviour {
//小球运动的速率
public float movementSpeed=6.0f;
//小球的水平运动
private Vector3 horizontalMovement;
//小球的前后运动
private Vector3 verticalMovement;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
//Vector3.right x zhou
horizontalMovement=Input.GetAxis("Horizontal")*Vector3.right*movementSpeed;
//z zhou
verticalMovement=Input.GetAxis("Vertical")*Vector3.forward*movementSpeed;
//小球的运动
Vector3 movement=horizontalMovement+verticalMovement;
//为小球施加力
rigidbody.AddForce(movement,ForceMode.Force);
}
void OnTriggerEnter(collider other)
{
//判断小球是否与钻石对象碰撞
if (other.tag == "Pickup")
{
//销毁对象
Destroy(other.gameObject);
}
}
}
我是照着网上的教程做的,代码有错误: Assets/Script/BallControl.cs(44,21): error CS0246: The type or namespace name `collider' could not be found. Are you missing a using directive or an assembly reference?
请问这是怎么回事,应该怎么改?
using System.Collections;
public class BallControl : MonoBehaviour {
//小球运动的速率
public float movementSpeed=6.0f;
//小球的水平运动
private Vector3 horizontalMovement;
//小球的前后运动
private Vector3 verticalMovement;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
//Vector3.right x zhou
horizontalMovement=Input.GetAxis("Horizontal")*Vector3.right*movementSpeed;
//z zhou
verticalMovement=Input.GetAxis("Vertical")*Vector3.forward*movementSpeed;
//小球的运动
Vector3 movement=horizontalMovement+verticalMovement;
//为小球施加力
rigidbody.AddForce(movement,ForceMode.Force);
}
void OnTriggerEnter(collider other)
{
//判断小球是否与钻石对象碰撞
if (other.tag == "Pickup")
{
//销毁对象
Destroy(other.gameObject);
}
}
}
我是照着网上的教程做的,代码有错误: Assets/Script/BallControl.cs(44,21): error CS0246: The type or namespace name `collider' could not be found. Are you missing a using directive or an assembly reference?
请问这是怎么回事,应该怎么改?



