| 1234567891011121314151617181920212223242526272829 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class CollisionEnter : MonoBehaviour
- {
- private Rigidbody rigidbody;
- // Start is called before the first frame update
- void Start()
- {
- rigidbody = GetComponent<Rigidbody>();
- if (rigidbody == null)
- {
- rigidbody = gameObject.AddComponent<Rigidbody>();
- }
- }
- private void OnCollisionEnter(Collision collision)
- {
- //print(name +" " + collision.gameObject.name);
- rigidbody.useGravity = true;
- rigidbody.mass = 0.1f;
- }
- // Update is called once per frame
- void Update()
- {
- // transform.position = new Vector3(transform.position.x, transform.position.y - 0.01f * Time.deltaTime, transform.position.z);
- }
- }
|