File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments