-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTree.cs
More file actions
42 lines (33 loc) · 1.27 KB
/
Tree.cs
File metadata and controls
42 lines (33 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Tree : MonoBehaviour
{
private Vector3 pos;
private Renderer rend, rend2;
public Material mat;
public GameObject self, leaves;
public Rigidbody r1, r2;
// Start is called before the first frame update
void Start()
{
rend = self.GetComponent<Renderer>();
rend2 = leaves.GetComponent<Renderer>();
r1 = self.GetComponent<Rigidbody>();
r2 = leaves.GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
}
void OnCollisionEnter(Collision collisionInfo)
{
if (collisionInfo.collider.tag == "Bullet")
{
rend.material = mat;
rend2.material = mat;
r1.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
r2.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
}
}
}