Up自制Unity預制腳本grabbable.cs
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine;
public class grabbable : MonoBehaviour
{
? ? public bool grabable = true;
? ? //用來標記物件是不是可以被抓取
? ? // Start is called before the first frame update
? ? void Start()
? ? {
? ? ? ? transform.GetComponent<Rigidbody>().drag = 5;
? ? ? ? transform.GetComponent<Rigidbody>().angularDrag = 10;
? ? ? ? //增加物體移動和旋轉(zhuǎn)阻力,免得動不動就到處亂飄。
? ? ? ? //注意別忘了給物體添加Rigidbody組件和collide組件啊,不然這個腳本就沒用,而且會報錯。
? ? }
? ? // Update is called once per frame
? ? void Update()
? ? {? ? ? ??
? ? }
}
標簽: