@@ -140,17 +140,17 @@ export function createKoiSchool(scene, gradientMap, pondRadius) { |
| 140 | koi.group.position.z - z | 140 | koi.group.position.z - z |
| 141 | ) | 141 | ) |
| 142 | | 142 | |
| 143 | - if (dist < 2) { | 143 | + if (dist < 1.5) { |
| 144 | koi.state.panicMode = true | 144 | koi.state.panicMode = true |
| 145 | - koi.state.panicTimer = 1.5 + Math.random() * 1 | 145 | + koi.state.panicTimer = 0.8 + Math.random() * 0.6 // Shorter panic |
| 146 | - koi.state.speed = 4 + Math.random() * 2 | 146 | + koi.state.speed = koi.state.baseSpeed * 2 // Just double speed, not crazy fast |
| 147 | | 147 | |
| 148 | - // Flee away from the bread | 148 | + // Flee away from the bread - but keep it smooth |
| 149 | const fleeAngle = Math.atan2( | 149 | const fleeAngle = Math.atan2( |
| 150 | koi.group.position.z - z, | 150 | koi.group.position.z - z, |
| 151 | koi.group.position.x - x | 151 | koi.group.position.x - x |
| 152 | ) | 152 | ) |
| 153 | - const fleeDist = pondRadius * 0.6 + Math.random() * pondRadius * 0.2 | 153 | + const fleeDist = pondRadius * 0.5 + Math.random() * pondRadius * 0.3 |
| 154 | koi.state.targetX = Math.cos(fleeAngle) * fleeDist | 154 | koi.state.targetX = Math.cos(fleeAngle) * fleeDist |
| 155 | koi.state.targetZ = Math.sin(fleeAngle) * fleeDist | 155 | koi.state.targetZ = Math.sin(fleeAngle) * fleeDist |
| 156 | | 156 | |
@@ -184,9 +184,9 @@ export function createKoiSchool(scene, gradientMap, pondRadius) { |
| 184 | s.isIdle = false | 184 | s.isIdle = false |
| 185 | pickNewTarget(koi, pondRadius) | 185 | pickNewTarget(koi, pondRadius) |
| 186 | } | 186 | } |
| 187 | - // Gentle drifting while idle | 187 | + // Gentle drifting while idle - still wiggle tail slowly |
| 188 | - koi.tail.rotation.y = Math.sin(elapsed * 4 + s.flickerPhase) * 0.2 | 188 | + koi.tail.rotation.y = Math.sin(elapsed * 3 + s.flickerPhase) * 0.15 |
| 189 | - koi.group.position.y = -0.1 + Math.sin(elapsed * 3 + s.flickerPhase) * 0.01 | 189 | + koi.group.position.y = -0.1 + Math.sin(elapsed * 2 + s.flickerPhase) * 0.008 |
| 190 | continue | 190 | continue |
| 191 | } | 191 | } |
| 192 | | 192 | |
@@ -194,85 +194,77 @@ export function createKoiSchool(scene, gradientMap, pondRadius) { |
| 194 | s.wanderTimer -= delta | 194 | s.wanderTimer -= delta |
| 195 | if (s.wanderTimer <= 0 && !s.panicMode) { | 195 | if (s.wanderTimer <= 0 && !s.panicMode) { |
| 196 | // Random chance to go idle | 196 | // Random chance to go idle |
| 197 | - if (Math.random() < 0.15) { | 197 | + if (Math.random() < 0.2) { |
| 198 | s.isIdle = true | 198 | s.isIdle = true |
| 199 | - s.idleTimer = 1 + Math.random() * 3 | 199 | + s.idleTimer = 2 + Math.random() * 4 |
| 200 | s.wanderTimer = 0.5 | 200 | s.wanderTimer = 0.5 |
| 201 | continue | 201 | continue |
| 202 | } | 202 | } |
| 203 | | 203 | |
| 204 | - // Sometimes follow another koi (if sociable) | 204 | + // Sometimes follow another koi loosely (if sociable) |
| 205 | if (Math.random() < s.sociability && kois.length > 1) { | 205 | if (Math.random() < s.sociability && kois.length > 1) { |
| 206 | const otherKoi = kois[Math.floor(Math.random() * kois.length)] | 206 | const otherKoi = kois[Math.floor(Math.random() * kois.length)] |
| 207 | if (otherKoi !== koi) { | 207 | if (otherKoi !== koi) { |
| 208 | - // Head toward where they're going, with some offset | 208 | + // Head toward where they are, with some offset |
| 209 | - s.targetX = otherKoi.state.targetX + (Math.random() - 0.5) * 1.5 | 209 | + s.targetX = otherKoi.group.position.x + (Math.random() - 0.5) * 2 |
| 210 | - s.targetZ = otherKoi.state.targetZ + (Math.random() - 0.5) * 1.5 | 210 | + s.targetZ = otherKoi.group.position.z + (Math.random() - 0.5) * 2 |
| 211 | } | 211 | } |
| 212 | } else { | 212 | } else { |
| 213 | pickNewTarget(koi, pondRadius) | 213 | pickNewTarget(koi, pondRadius) |
| 214 | } | 214 | } |
| 215 | | 215 | |
| 216 | - // Restless koi change direction more often | 216 | + // Longer wander intervals for more natural movement |
| 217 | - s.wanderTimer = (1 + Math.random() * 3) / s.restlessness | 217 | + s.wanderTimer = 2 + Math.random() * 4 |
| 218 | } | 218 | } |
| 219 | | 219 | |
| 220 | - // Move toward target | 220 | + // Move toward target - smooth, natural swimming |
| 221 | const dx = s.targetX - koi.group.position.x | 221 | const dx = s.targetX - koi.group.position.x |
| 222 | const dz = s.targetZ - koi.group.position.z | 222 | const dz = s.targetZ - koi.group.position.z |
| 223 | const dist = Math.hypot(dx, dz) | 223 | const dist = Math.hypot(dx, dz) |
| 224 | | 224 | |
| 225 | - if (dist > 0.15) { | 225 | + // Always swim forward, turn gradually |
| 226 | - // Calculate target rotation | | |
| 227 | const targetRot = Math.atan2(dx, dz) | 226 | const targetRot = Math.atan2(dx, dz) |
| 228 | | 227 | |
| 229 | - // Smooth rotation - varies by individual | 228 | + // Very smooth rotation - fish don't turn sharply |
| 230 | let rotDiff = targetRot - koi.group.rotation.y | 229 | let rotDiff = targetRot - koi.group.rotation.y |
| 231 | while (rotDiff > Math.PI) rotDiff -= Math.PI * 2 | 230 | while (rotDiff > Math.PI) rotDiff -= Math.PI * 2 |
| 232 | while (rotDiff < -Math.PI) rotDiff += Math.PI * 2 | 231 | while (rotDiff < -Math.PI) rotDiff += Math.PI * 2 |
| 233 | - koi.group.rotation.y += rotDiff * s.turnSpeed * delta | | |
| 234 | | 232 | |
| 235 | - // Move forward - speed varies | 233 | + // Slower turn rate for natural movement |
| 236 | - const moveSpeed = s.panicMode ? s.speed * 2.5 : s.speed * (0.4 + s.restlessness * 0.4) | 234 | + const turnRate = s.panicMode ? 2.5 : 1.2 |
| | 235 | + koi.group.rotation.y += rotDiff * turnRate * delta |
| | 236 | + |
| | 237 | + // Always moving forward (fish don't stop mid-water) |
| | 238 | + const moveSpeed = s.panicMode ? s.speed * 1.8 : s.speed * 0.5 |
| 237 | const moveX = Math.sin(koi.group.rotation.y) * moveSpeed * delta | 239 | const moveX = Math.sin(koi.group.rotation.y) * moveSpeed * delta |
| 238 | const moveZ = Math.cos(koi.group.rotation.y) * moveSpeed * delta | 240 | const moveZ = Math.cos(koi.group.rotation.y) * moveSpeed * delta |
| 239 | koi.group.position.x += moveX | 241 | koi.group.position.x += moveX |
| 240 | koi.group.position.z += moveZ | 242 | koi.group.position.z += moveZ |
| 241 | | 243 | |
| 242 | - // Tail wiggle - faster when moving fast | 244 | + // Tail wiggle - proportional to speed |
| 243 | - const wiggleSpeed = s.panicMode ? 25 : 8 + s.restlessness * 8 | 245 | + const wiggleSpeed = s.panicMode ? 15 : 8 |
| 244 | - koi.tail.rotation.y = Math.sin(elapsed * wiggleSpeed + s.flickerPhase) * 0.5 | 246 | + const wiggleAmount = s.panicMode ? 0.4 : 0.3 |
| 245 | - } else { | 247 | + koi.tail.rotation.y = Math.sin(elapsed * wiggleSpeed + s.flickerPhase) * wiggleAmount |
| 246 | - // Reached target - maybe idle, maybe pick new target | 248 | + |
| 247 | - if (Math.random() < 0.3) { | 249 | + // Reached close to target - pick new one |
| | 250 | + if (dist < 0.3) { |
| | 251 | + if (Math.random() < 0.25) { |
| 248 | s.isIdle = true | 252 | s.isIdle = true |
| 249 | - s.idleTimer = 0.5 + Math.random() * 2 | 253 | + s.idleTimer = 1 + Math.random() * 3 |
| 250 | } else { | 254 | } else { |
| 251 | pickNewTarget(koi, pondRadius) | 255 | pickNewTarget(koi, pondRadius) |
| 252 | } | 256 | } |
| 253 | } | 257 | } |
| 254 | | 258 | |
| 255 | - // Flicker/shimmer effect - slight Y oscillation | 259 | + // Gentle depth variation - natural swimming motion |
| 256 | - koi.group.position.y = -0.08 + Math.sin(elapsed * 8 + s.flickerPhase) * 0.015 | 260 | + koi.group.position.y = -0.08 + Math.sin(elapsed * 3 + s.flickerPhase) * 0.01 |
| 257 | - | | |
| 258 | - // Erratic depth changes when panicked | | |
| 259 | - if (s.panicMode) { | | |
| 260 | - koi.group.position.y += Math.sin(elapsed * 20 + s.flickerPhase) * 0.03 | | |
| 261 | - // Random direction jitters | | |
| 262 | - if (Math.random() < delta * 5) { | | |
| 263 | - koi.group.rotation.y += (Math.random() - 0.5) * 0.8 | | |
| 264 | - pickNewTarget(koi, pondRadius) | | |
| 265 | - } | | |
| 266 | - } | | |
| 267 | | 261 | |
| 268 | - // Keep in pond bounds | 262 | + // Keep in pond bounds - smooth turnaround |
| 269 | const currentDist = Math.hypot(koi.group.position.x, koi.group.position.z) | 263 | const currentDist = Math.hypot(koi.group.position.x, koi.group.position.z) |
| 270 | - if (currentDist > pondRadius * 0.9) { | 264 | + if (currentDist > pondRadius * 0.85) { |
| 271 | - const scale = (pondRadius * 0.85) / currentDist | 265 | + // Steer back toward center |
| 272 | - koi.group.position.x *= scale | 266 | + s.targetX = (Math.random() - 0.5) * pondRadius * 0.5 |
| 273 | - koi.group.position.z *= scale | 267 | + s.targetZ = (Math.random() - 0.5) * pondRadius * 0.5 |
| 274 | - // Turn back toward center | | |
| 275 | - pickNewTarget(koi, pondRadius * 0.5) | | |
| 276 | } | 268 | } |
| 277 | } | 269 | } |
| 278 | } | 270 | } |