#How can players push eachother in multiplayer?
1 messages · Page 1 of 1 (latest)
You have to apply velocity to that player
I assume you want to push that player away from the other player
...I have no idea how to do that.
Good luck!
Someone else who can do this??
A Raycast3D is literally just a vector. If you've already used it for collision you can use it to apply velocity in the same direction. Eg.
var push_speed: float = 200.0
collider.velocity += ray.target_position.normalized() * push_speed```
I wrote the code same as u gave me but didn't worked and also it's showing no error but when pressing the push button the 2nd players doesn't gets pushed.
I also let u know that i am doing this in Multiplayer 3d.
I hope it wasn't exact, it's meant to be adapted. Assuming that's what you meant though, post your code and I'll take a look.
if $pushBtn.is_pressed():
var collider = player_ray_cast3d.get_collider()
if collider is CharacterBody3D:
collider.velocity += player_ray_cast3d.target_position.normlized() * push_player_speed
since my game is multiplayer, do i have to use something different for this?
At the moment it's only applying it client side. You'll need to ensure that information also gets sent to the relevant player to knock them backwards.
Can someone else know how players can push eachother??