Godot Version
4.2.2
Question
i have 2 player node that can colide with each other (they are meant to)
P1 can’t go inside P2 but for some reason P2 can go inside P1
P1 has the normal movement code
P2 has
if Record.time_left > 0:
var Parray=clamp(current_position,0,future_positions.size()-1)
future_positions = get_parent().get_node("player").past_positions
#global_position = future_positions[Parray]
current_position = Parray+1
self.position = self.position.move_toward(future_positions[Parray], 5)
previusly i was using the hashed code to move P2 but bothed ended with the intersection
i have messed around with collision priority but that doesnt fix it
it also apears that even if P1 has higher velocity.x they cant escape P2 unless they jump
You also shouldn’t change position directly as this will bypass collision detection.
If these are character nodes use move_and_slide. If these are rigid bodies use forces.
1 Like
[sry for late reply]
how would i use move_slide() to move P2?
P2 needs to follow a array*
(P2 is a clone of P1 that follow recorded movement made by player)
1 Like
i also have a array containing the players velocity
if i instead made P2 have the same velocity as P1 would that fix everything?
(ill test this in a bit)
Okay, that makes things tricky. You could possibly do a check before moving.
yeah so my idea didnt work
P2 moved but only in 1 direction despite there being negative velocity
any suggestions?
wether it be editing my code or changing how i move P2 entirly
i still have no idea what these P1 and P2 made of, is it characterbody or not
both are character bodies
trying useing rigid but couldnt move the collision and pysicalbone had a similar problem from memory
in your _physics_process(delta) function, do you have move_and_slide() called? or did you remove it
I removed it though i did just re-added it in for the velocity.x test
ill try it again with the previous code
you shouldnt remove it, many posts reported here regarding overlapped characterbody, because they removed that move_and_slide() line
1 Like
yep that was doing it
thanks again for the help
all the best to you
1 Like
system
Closed
13
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.