-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjectController.cs
More file actions
35 lines (26 loc) · 971 Bytes
/
ObjectController.cs
File metadata and controls
35 lines (26 loc) · 971 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
26
27
28
29
30
31
32
33
34
35
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ObjectController : MonoBehaviour {
private Quaternion originalRotation;
public GameObject originalTransform;
public bool placed = false;
private Rigidbody2D myRb;
private void Awake() {
originalRotation = transform.rotation;
this.myRb = this.gameObject.GetComponent<Rigidbody2D>();
}
public Quaternion getOriginalRotation() {
return originalRotation;
}
public Transform getOriginalTransform() {
return originalTransform.transform;
}
public void letsPlay() {
this.myRb.simulated = true;
this.myRb.AddTorque(50f);
Vector2 direction = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f));
this.myRb.AddForce(direction * 250f);
Debug.Log("Er vector " + direction + "de " + this.gameObject);
}
}