#Trying to make a Grenade bullet that launches the player.

1 messages · Page 1 of 1 (latest)

rugged steppe
#

I have no idea how i can make the grenade launch the player in the correct direction upon explosion and what force to apply based on said collision

grim hearth
#

What do you have so far?

rapid helm
#

Are you trying to implement rocket jumping? That's what it sounds like

#

That's basically just knockback. It could look something like this:

var force: float = 15.0
var knockback: Vector3 = (explosion.global_position.direction_to(player.global_position) + Vector3.UP)
#

This is my implementation of it, which is simple but it works. In Team Fortress 2, Valve added a slight amount of upward force to explosion-based knockback to facilitate launching players so that's why I have Vector3.UP here

#

And then on the actor that you're pushing, in this case the player, you'd do something like this:

player.velocity += ((force * knockback))
rugged steppe
rapid helm
#

That's right, it's the same concept

#

You find the direction between the explosion and the object being hit by the explosion, and you use that as the directional component of your knockback vector

#

And combine that with force as the magnitude

#

The Vector3.UP part is optional, and for 2D I would probably only use it in a sidescroller type game

rugged steppe
#

Thanks!