Skip to content

Commit cfb9ad1

Browse files
author
Roberto De Ioris
authored
Create Physics_API.md
1 parent 697e4d8 commit cfb9ad1

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

docs/Physics_API.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# The Physics API
2+
3+
The 'set_simulate_physics' method is exposed for enabling physic on PrimitiveComponent.
4+
5+
Remember that you cannot enable physics withotu setting the collision presetes accordingly:
6+
7+
```py
8+
9+
# PyActor with a staticmeshcomponent (a sphere)
10+
# when overlapped it became a physic object
11+
class Ball:
12+
13+
def begin_play(self):
14+
self.sphere = self.uobject.get_actor_component_by_type(ue.find_class('StaticMeshComponent'))
15+
16+
def tick(self, delta_time):
17+
pass
18+
19+
def on_actor_begin_overlap(self, me, other_actor):
20+
# change collision profile
21+
self.sphere.call('SetCollisionProfileName BlockAll')
22+
# enable physics
23+
self.sphere.set_simulate_physics()
24+
25+
# once the object became a physics one, hit event will start arriving
26+
def on_actor_hit(self, me, other, *args):
27+
ue.print_string('HIT with ' + other.get_name())
28+
```
29+
30+
TODO: expose more physics functions, expecially the one for applying forces

0 commit comments

Comments
 (0)