|
|
|
|
Reply From: |
Bartosz |
First retrieve list of overlapping boddies var bodies = area.get_overlapping_bodies()
Then check if boddies contains your body of interest if bodies.has(my_rigidbody): do_some_stuff();
Then check if boddies contains your body of interest if
bodies.has(my_rigidbody): do_some_stuff();
Bartosz, I do not need to check for intersection with a particular body (a scene node), but make sure that the intersection has occurred with any RigidBody. How to do it?
DimitriyPS | 2018-03-28 07:41
just check area.get_overlapping_bodies().empty()
true
means there are no overlapping bodies, false
means there is at least one overlapping body
Bartosz | 2018-03-28 19:10
Bartosz, that’s not what I wanted. I want to know the body type (node type) with which the intersection occurred (what this body: RigidBody, KinematicBody, StaticBody, etc.).
DimitriyPS | 2018-03-29 07:12
are yout asking about type check like this if body is RigidBody2D: do_something()
?
Bartosz | 2018-03-29 19:02
are yout asking about type check like this if body is RigidBody2D:
do_something() ?
I don’t speak English. Probably… Yes.
I need:
- check check intersection with Area (true/false)
- If the intersection eat to check the body type, with which intersected Area
This is how it worked in Godot 2.X:
if lp_Testor.get_overlapping_bodies().size()>0:
var n=0
for n in range(lp_Testor.get_overlapping_bodies().size()):
if lp_Testor.get_overlapping_bodies()[n] extends RigidBody:
lp_Testor.get_overlapping_bodies()[n].apply_impulse(Vector3(),Vector3(lp_Testor.get_overlapping_bodies()[n].get_mass()*4,0,0))
marker_Deystvie=4
lp_OstatokVremya=lc_Ogidanie_2
In Godot 3.X it does not work.
DimitriyPS | 2018-03-30 07:27
I’ve removed unnecessary if
, replace indexing by number n
with directly iterating elements and I’m using is
instead of extends
rest is your code:
for body in lp_Testor.get_overlapping_bodies():
if body is RigidBody:
body.apply_impulse(Vector3(),Vector3(body.get_mass()*4,0,0))
marker_Deystvie=4
lp_OstatokVremya=lc_Ogidanie_2
Bartosz | 2018-03-30 18:12