Tree Chopping
So in my game, i programed so the first person (me) whould chop down a tree, then it would fall and coconuts and wood would spawn next to it. but i have 3 errors that i could not find how to fix. ( i even did some research).
Here are the errors:
Assets/Part 4 - Tree Chopping/TreeController.js(14,49): BCE0043: Unexpected token: ).
Assets/Part 4 - Tree Chopping/TreeController.js(14,50): BCE0044: expecting ), found '.'.
Assets/Part 4 - Tree Chopping/TreeController.js(14,51): UCE0001: ';' expected. Insert a semicolon at the end.
Here is the code:
code:
#pragma strict
var treeHealth : int = 5;
var logs : Transform;
var coconut : Transform;
var tree : GameObject;
var speed : int = 8;
function Start()
{
tree = this.gameObject;
this.gameObject.GetComponent<Rigidbody>().isKinematic = true;
}
function Update()
{
if(treeHealth <= 0)
{
rigidbody.isKinematic = false;
rigidbody.AddForce(transform.forward * speed);
DestroyTree();
}
}
function DestroyTree()
{
yield WaitForSeconds(7);
Destroy(tree);
var position : Vector3 = Vector3(Random.Range(-1.0, 1.0), 0, Random.Range(-1.0, 1.0));
Instantiate(logs, tree.transform.position + Vector3(0,0,0) + position, Quaternion.identity);
Instantiate(logs, tree.transform.position + Vector3(2,2,0) + position, Quaternion.identity);
Instantiate(logs, tree.transform.position + Vector3(5,5,0) + position, Quaternion.identity);
Instantiate(coconut, tree.transform.position + Vector3(0,0,0) + position, Quaternion.identity);
Instantiate(coconut, tree.transform.position + Vector3(2,2,0) + position, Quaternion.identity);
Instantiate(coconut, tree.transform.position + Vector3(5,5,0) + position, Quaternion.identity);
}
Is there something i did wrong?
Your answer
Follow this Question
Related Questions
Weird Tree Shading 0 Answers
Acces terrain tree to simulate wind (Voxel trees) 0 Answers
How should I make Grass in HDRP 2020? 0 Answers
Terrain Tree Index Removed, But Sometimes Not And I got An Error 0 Answers
Unity 2018, create wind on fbx. 0 Answers