how can i find logic and physics behind rocket jumping in tf2 because i want to recreate…
- User
how can i find logic and physics behind rocket jumping in tf2 because i want to recreate it in unreal
- Assistant
Recreating TF2-style rocket‐jumping in Unreal is really just a matter of (a) modelling how TF2 computes its “knockback” impulse and then (b) applying that same impulse to your CharacterMovementComponent (or physics body) in Unreal. Below is a roadmap plus some “ready-to-plug-in” pseudo-code/blueprint tips.
—------------------------------------------------
1. Understand the TF2 “Knockback” model
- TF2 treats the rocket’s explosion as an instantaneous impulse on any nearby player.
- Impulse magnitude falls off linearly with distance:
• At explosion center: 100% of base impulse
• At max radius R: 0% - Direction is simply from explosion → player.
- TF2 ignores friction/drag the moment you’re airborne—so you keep full impulse.
Mathematically:
let R = rocket_explosion_radius let d = clamp(distance(player, explosion), 0, R) let falloff = (R – d) / R // linear falloff factor ∈ [0…1] let I₀ = baseImpulse // engine constant, e.g. ~800–1000 units let I = I₀ * falloff // actual impulse magnitude let dir = normalize(playerPos – explosionPos) ⇒ appliedImpulse = dir * ITypical TF2 constants (approx):
• explosion_radius R ≃ 200 units
• baseImpulse I₀ ≃ 850 units
• gravity ≃ 650 units/s²—------------------------------------------------
2. Capture “Rocket Jump” in Unreal
A) Blueprint (Character)
- In your Rocket’s Explosion event,
SphereOverlapActors(radius R). - For each overlapping Character:
• Compute ―dir = Normalize(GetActorLocation() – ExplosionLocation)
• Compute ―d = Distance(...)
• Compute ―falloff = Clamp((R–d)/R, 0,1)
• Compute ―impulse = dir * (BaseImpulse * falloff)
• Call ⇒ Launch Character (in Movement)
– World Direction * Velocity: use yourimpulsevector
– Check “Override X/Y” & “Override Z” if you want exact control
B) C++ (CharacterMovementComponent)
// In your Explosion-handling code: void ApplyRocketJump(ACharacter* Victim, FVector ExplosionLoc) { const float R = 200.f; // explosion radius const float BaseImpulse = 850.f; // tweakable FVector toVictim = Victim->GetActorLocation() - ExplosionLoc; float d = toVictim.Size(); if (d >= R) return; float falloff = FMath::Clamp((R - d) / R, 0.f, 1.f); FVector dir = toVictim.GetSafeNormal(); FVector impulse = dir * (BaseImpulse * falloff); // Option 1: LaunchCharacter hard-set Victim->LaunchCharacter(impulse, true, true); // Option 2: Add impulse via movement component // Victim->GetCharacterMovement()->AddImpulse(impulse, true); }—------------------------------------------------
3. Tuning & “Gotchas”
- Gravity scaling: Unreal default g≈980 cm/s². TF2 uses ~650. You may want to lower your CharacterMovementComponent→GravityScale for closer “feel.”
- Air control: TF2 lets you tweak “airaccelerate” so you can maneuver mid-jump. In Unreal, adjust
Air Controlin your MovementComponent. - Fall damage: TF2 usually nullifies fall-damage if you rocket-jump. You can override
Landed()to disable damage if last impulse was a rocket-jump. - Crouch-jumping: If you want the classic crouch+jump height boost, add a small upward offset to your impulse when the player is crouching.
—------------------------------------------------
4. Further Reading & References
- TF2 Wiki on Rocket Jumping:
‣ https://wiki.teamfortress.com/wiki/Rocket_jump - Source SDK code (look for
CBaseEntity::ApplyAbsVelocityImpulse&CGamemovement::AddVelocityin GameMovement.cpp) - Unreal docs:
‣ LaunchCharacter: https://docs.unrealengine.com/en-US/API/Runtime/Engine/GameFramework/Character/LaunchCharacter
—------------------------------------------------
With this in place, you should see your Unreal character “rocket-jump” just like in TF2. TweakBaseImpulse,radiusand your gravity/air-control settings until it feels right. Good luck—and happy rocket-jumping! 🚀
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.