Falco Engine 3.9.0.1 (beta)
Rigidbody.cs
Go to the documentation of this file.
1using System;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5namespace FalcoEngine
6{
7 public class Rigidbody : Component
8 {
9 internal Rigidbody()
10 {
11
12 }
13
14 /*----------- PUBLIC ------------*/
15
20 {
21 get
22 {
23 INTERNAL_get_position(out Vector3 value);
24 return value;
25 }
26 set
27 {
28 INTERNAL_set_position(ref value);
29 }
30 }
31
36 {
37 get
38 {
39 INTERNAL_get_rotation(out Quaternion value);
40 return value;
41 }
42 set
43 {
44 INTERNAL_set_rotation(ref value);
45 }
46 }
47
53 {
54 get
55 {
56 INTERNAL_get_linear_velocity(out Vector3 value);
57 return value;
58 }
59 set
60 {
61 INTERNAL_set_linear_velocity(ref value);
62 }
63 }
64
69 {
70 get
71 {
72 INTERNAL_get_angular_velocity(out Vector3 value);
73 return value;
74 }
75 set
76 {
77 INTERNAL_set_angular_velocity(ref value);
78 }
79 }
80
85 public float friction { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }
86
92 public float bounciness { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }
93
97 public float linearDamping { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }
98
102 public float angularDamping { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }
103
107 public bool isKinematic
108 {
109 get
110 {
111 return INTERNAL_get_is_kinematic();
112 }
113 set
114 {
115 INTERNAL_set_is_kinematic(value);
116 }
117 }
118
122 public bool isStatic { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }
123
129 public bool isTrigger { [MethodImpl(MethodImplOptions.InternalCall)] get; }
130
134 public float mass
135 {
136 get
137 {
138 return INTERNAL_get_mass();
139 }
140 set
141 {
142 INTERNAL_set_mass(value);
143 }
144 }
145
150 public void AddForce(Vector3 force)
151 {
152 AddForce(force, Vector3.zero);
153 }
154
160 public void AddForce(Vector3 force, Vector3 rel_pos)
161 {
162 INTERNAL_add_force(ref force, ref rel_pos);
163 }
164
169 public void AddTorque(Vector3 torque)
170 {
171 INTERNAL_add_torque(ref torque);
172 }
173
180 [MethodImpl(MethodImplOptions.InternalCall)]
181 public extern void SetFreezePosition(bool freezeX, bool freezeY, bool freezeZ);
182
189 [MethodImpl(MethodImplOptions.InternalCall)]
190 public extern void SetFreezeRotation(bool freezeX, bool freezeY, bool freezeZ);
191
192 /*----------- INTERNAL CALLS ------------*/
193
194 [MethodImpl(MethodImplOptions.InternalCall)]
195 private extern void INTERNAL_get_position(out Vector3 value);
196
197 [MethodImpl(MethodImplOptions.InternalCall)]
198 private extern void INTERNAL_set_position(ref Vector3 value);
199
200 [MethodImpl(MethodImplOptions.InternalCall)]
201 private extern void INTERNAL_get_rotation(out Quaternion value);
202
203 [MethodImpl(MethodImplOptions.InternalCall)]
204 private extern void INTERNAL_set_rotation(ref Quaternion value);
205
206 [MethodImpl(MethodImplOptions.InternalCall)]
207 private extern void INTERNAL_get_linear_velocity(out Vector3 value);
208
209 [MethodImpl(MethodImplOptions.InternalCall)]
210 private extern void INTERNAL_set_linear_velocity(ref Vector3 value);
211
212 [MethodImpl(MethodImplOptions.InternalCall)]
213 private extern void INTERNAL_get_angular_velocity(out Vector3 value);
214
215 [MethodImpl(MethodImplOptions.InternalCall)]
216 private extern void INTERNAL_set_angular_velocity(ref Vector3 value);
217
218 [MethodImpl(MethodImplOptions.InternalCall)]
219 private extern void INTERNAL_add_force(ref Vector3 force, ref Vector3 rel_pos);
220
221 [MethodImpl(MethodImplOptions.InternalCall)]
222 private extern void INTERNAL_add_torque(ref Vector3 torque);
223
224 [MethodImpl(MethodImplOptions.InternalCall)]
225 private extern bool INTERNAL_get_is_kinematic();
226
227 [MethodImpl(MethodImplOptions.InternalCall)]
228 private extern void INTERNAL_set_is_kinematic(bool value);
229
230 [MethodImpl(MethodImplOptions.InternalCall)]
231 private extern float INTERNAL_get_mass();
232
233 [MethodImpl(MethodImplOptions.InternalCall)]
234 private extern void INTERNAL_set_mass(float value);
235 }
236}
float bounciness
How bouncy is the surface? A value of 0 will not bounce A value of 1 will bounce without any loss of ...
Definition: Rigidbody.cs:92
void SetFreezeRotation(bool freezeX, bool freezeY, bool freezeZ)
Controls whether physics will change the rotation of the object
bool isKinematic
Controls whether physics affects the rigidbody
Definition: Rigidbody.cs:108
Vector3 angularVelocity
The angular velocity vector of the rigidbody measured in radians per second
Definition: Rigidbody.cs:69
float angularDamping
The angular drag of the object
Definition: Rigidbody.cs:102
void AddTorque(Vector3 torque)
Adds a torque to the rigidbody
Definition: Rigidbody.cs:169
Quaternion rotation
The rotation of the rigidbody
Definition: Rigidbody.cs:36
bool isStatic
Static objects behave like a wall or a floor which can only affect the other objects and not moving
Definition: Rigidbody.cs:122
float linearDamping
The drag of the object
Definition: Rigidbody.cs:97
float friction
The friction of an object Usually a value from 0 to 1. A value of zero feels like ice,...
Definition: Rigidbody.cs:85
void SetFreezePosition(bool freezeX, bool freezeY, bool freezeZ)
Controls whether physics will change the position of the object
void AddForce(Vector3 force, Vector3 rel_pos)
Adds a force to the rigidbody relative to its coordinate system
Definition: Rigidbody.cs:160
float mass
The mass of the rigidbody
Definition: Rigidbody.cs:135
bool isTrigger
Is the collider a trigger? A trigger doesn't register a collision with an incoming rigidbody Instead,...
Definition: Rigidbody.cs:129
Vector3 linearVelocity
The velocity vector of the rigidbody It represents the rate of change of rigidbody position
Definition: Rigidbody.cs:53
Vector3 position
The position of the rigidbody
Definition: Rigidbody.cs:20
void AddForce(Vector3 force)
Adds a force to the rigidbody
Definition: Rigidbody.cs:150
static Vector3 zero
Definition: Vector3.cs:67