#How can players push eachother in multiplayer?

1 messages · Page 1 of 1 (latest)

mossy crystal
#

In my 3d multiplayer game, in characterBody3D:

if $pushBtn.is_pressed():
var collider = player_ray_cast3d.get_collider()

if collider is CharacterBody3D:
   then how to push player??
tribal moon
#

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!

mossy crystal
#

Someone else who can do this??

restive matrix
#

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```
mossy crystal
restive matrix
#

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.

mossy crystal
restive matrix
#

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.

mossy crystal
#

Can someone else know how players can push eachother??