|Topic was automatically imported from the old Question2Answer platform.
Hi, i’m stuck, i’m making the base of a platformer 3d game but i just run into a problem my player (kinematicBody) can’t grab a collectible (an instanced spatial node with a an “Area” as a child), so let me explain it a little better:
my collectible node it’s a blender model with U/V maps (exported with the better collada exporter)
it’s simple my player may enter the colission shape and that should trigger the animation for been taken however nothing happens
when the level loads my player (golfball) loads first then loads my collectible (EnergyC) energy connect the body_entered signal of his child area:
var taken = false
$Energy.connect("body_entered", self, "trigger")
# if body.has_method("energyg") and not taken:
# taken = true
taken = true
if Input.is_action_pressed("act_mas") and not taken:
I test with the simple animation alone to test if my
body.has_method("energyg") was the problem however the problem persist. i also test de play animation code putting it in into pressing a button and it worked just fine.
my player node moves with
move_and_slide and it’s physics are in
_physics_process it collide without problems with static and rigid bodys
my collectible node have and area as a child this area is monitoring and it’s monitorable it has two collision shapes neither of them are disable : here
the coins from the 3D platform demo works just fine and i also made the fps tutorial from the godotdocs web and i had colletibles node that were spatial nodes with area nodes as childs, this level have other scrips with connected signals working it’s just this one that doesn’t trigger
Thanks in advance, if you need any aditional information i will anwser as soon as I can
First, for debugging purposes, add “print” to body_entered, so you can rule out animation not playing. Second - what are the collision shape layers and masks defined on area & player?
gmaps | 2019-10-16 06:46
both the player and the colletible are in layer 1 and search mask 1, also doesn’t get any anwser with “print” either, since i can make other animation to play and other scripts do connect signals just fine i’m comfused…
if it helps the collectible node it’s doing an idle animation (it rotates itself and also goes up (y =0.5)and down (y=-0.5) of the spatial node origin) i use “rotation_degree” and “translation” from the animator: here, if I only make this node with the area child without the spatial node the “translation” function of the animation player will put the colletible at x=0 z=0 of mi “level node” with would be it’s “father node” origin position.
sorry for the delay I was up all day but didn’t actually see you coment the question, didn’t get any mail either i’ll be aware of any other information you need
Thanks in advance
OznerDNP | 2019-10-17 01:27
First of all, collision is based solely on physics objects - bodies with collision shapes, animations have nothing to do with them. There can be three issues that are most often: 1. Bodies not actually overlapping - check the layers & masks (you already did) and the shapes/radiuses of the bodies, you can also make them visible from the debug menu. Make sure they are overlapping. 2. signal not connected well - you can test if it works so you add this code for example:
var timer = 0
timer += delta
if timer > 5:
If the signal is connected well, it will trigger your action.
You should also make sure that both the character and energy are moving within _physics_process function with move_and_slide.
gmaps | 2019-10-17 12:40
ok so the emited signal of the “timer” worked… however the console got this error: here
this happen my before for not having and argument in “my target func” when i was connecting another signal however as you can see in the main post of this question my trigger func does have an argument (body) on it… so i’m not sure what to do…
also if I overlap my golfball(player) with the energy(colletible) the console wont emit any error. here
So now I know that my player physics code is in physicsprocess and that it’s moving with moveandslide however my energy doesn’t move with code at all. the translation function from the animator moves my energy node, i’m not sure if that is in physics process or if it’s going with moveandslide.
Thanks in advance
OznerDNP | 2019-10-17 20:58
Ok, so your signal is working fine, you get a console error because we didn’t provide any parameter when emitting signal manually in the upper code. Don’t worry about it.
Your signal is working fine, so it probably has something to do with collision shapes. If masks and layers on both are the same, the issue is probably that they’re not colliding.
Your screenshot is showing meshes, not collision shapes.
In the Debug menu choose “Visible Collision Shapes”, and check if collision shapes are colliding.
For starters, try having only two collision shapes - one sphere for the Area and a sphere for the character. Make sure they both have adequate radius.
Also see the priority of Area to default unless you really want it to be 1.
If you’re still having issues, you can create a smaller scene and post it here if you want, and I’ll fix it.
gmaps | 2019-10-18 10:26
Ok looks i just solve the problem so i had for my collectible a convex collision shape my player golfball have a simple sphere collission shape but I put it a convex to see if it will trigger this way but nothing happens: here
So after that I decide to make a simple sphere collision shape for both the player and the collectible it now works just fine
my problem it’s solve i’m not sure how to make this post as anwsered.
but just if I may ask if i have a more complex mesh for a collectible in the future how can i make my convex collision shape to actually detect bodys entering it?
Thank you for solving my problem ^-^
OznerDNP | 2019-10-18 17:46