🥎Bobber Controller
Controls the visual bobber: spawns it with a smooth arc or linear trajectory, animates it to the water surface, handles reeling physics, and retreats it back to the rod. Integrates with animation events via the IBobberSpawner interface.
✅ Requires: A bobber prefab (with optional
Alignerfor rotation) and references to the rod tip and fisher.
🔧 Inspector Settings
Bobber Prefab
The GameObject to instantiate as the bobber. Can be left empty for invisible fishing logic.
Rod Tip & Fisher Ref
Rod Tip: Where the bobber originates (e.g., fishing rod tip bone).
Fisher Ref: Used to align the bobber and calculate reeling direction.
Bobber Positioning
Spawn Interpolation (
0–1) Where along the line (or arc) between rod tip and water the bobber initially appears.0= at rod,1= at water.Use Arc Trajectory Enables a parabolic cast path for more natural motion.
Arc Height Peak height of the arc (only when arc trajectory is enabled).
Animation Settings
Animate to Surface If disabled, the bobber appears instantly at the water surface.
Animation Duration & Curve Controls how long and how smoothly the bobber moves from spawn point to water.
Retreat Animation Settings
Retreat Duration & Curve How the bobber returns to the rod when fishing ends.
Retreat Animation Percentage How long (as % of retreat time) the bobber tracks the moving rod tip.
Retreat Despawn When (as % of retreat time) to hide the bobber—useful for hiding it before the animation fully ends.
Retreat Position Offset Fine-tune the final retreat position, rotation, and scale (great for matching rod animations).
Reeling Settings
Base Reeling Speed How fast the bobber moves toward the player while reeling.
Reeling Bob Amount / Speed Adds subtle up/down motion during reeling for realism.
📈 Public Methods & Events
Events
OnBobberTouchWater— Fired when the bobber reaches the water surface.OnBobberExitWater— Fired when retreating begins.OnReelerComplete— Fired when reeling finishes (either by distance or proximity).
Key Methods
InformWaterHit(Vector3 point, LayerMask waterLayer)Called byFishingCasterto tell the bobber where the water surface is.StartReeling(float speed, float distance)Begins reeling the bobber toward the player. Called externally (e.g., by a reeling minigame).StopReeling()Immediately halts reeling motion.HandleFishingEnd()Cleans up state, hides the bobber, and resets tracking. Called when fishing is canceled or completed.
💡 The component automatically responds to
IBobberSpawnerevents (OnBobberSpawn,OnBobberRetreat)—usually triggered by animation events in your fishing state machine.
Last updated