-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateArchers.fs
More file actions
25 lines (19 loc) · 841 Bytes
/
CreateArchers.fs
File metadata and controls
25 lines (19 loc) · 841 Bytes
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
namespace FSharp
open UnityEngine
type CreateArchers() =
inherit MonoBehaviour()
[<SerializeField>]
let archer : GameObject = null;
[<SerializeField>]
let mutable gun : GameObject = null;
member this.Start() =
Debug.Log("Start")
this.Invoke("SpawnEnemy", 5.0f)
member this.SpawnEnemy() =
let heroTransform = GameObject.Find("Hero").gameObject.transform
let heroPosition = heroTransform.position
let enemyPosition = new Vector3(heroPosition.x - 1.0f, heroPosition.y, heroPosition.z)
let gunPosition = new Vector3(heroPosition.x + 0.5f, heroPosition.y, heroPosition.z)
let enemy = GameObject.Instantiate(archer, enemyPosition, Quaternion.identity)
let gun = GameObject.Instantiate(gun, gunPosition, Quaternion.identity)
()