pmndrs / pmndrs/ecctrl

当我将disableFollowCam从新设置为false时,这时候相机会突然回到之前disableFollowCam设置为true时的位置,即使我在相机移动时已经将人物的位置设置到新的位置。

Open
#121 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
797
Forks
98
Avg merge
8m
Merged PRs (30d)
1

Description

这是我的代码:它实现在第一人称视角的镜头动画,将镜头移动到某个位置。我期望,之后不会再回到动画前的位置。它就呆在哪儿,可是
`
const rigidRef = useRef(null); // 玩家所在刚体
const [disable, setDisable] = useState(false);

// 相机移动
function cameraMoveTo(to: Vector3) {
if (!camera) return;
setDisable(true);
new TWEEN.Tween(camera.position, tweenGroup)
.to(
{
x: to.x,
y: to.y,
z: to.z,
},
1800
)
.easing(TWEEN.Easing.Quartic.InOut)
.start()
.onComplete(() => {
setDisable(false);
rigidRef.current!.setTranslation(to, false);
});
}

cameraMoveTo(new Vector3(0.5, 1, 6));

<Ecctrl
  // 人物设置
  position={startPos}
  camInitDir={START_DIR}
  maxVelLimit={SPEED} // 人物移动速度
  turnVelMultiplier={1}
  turnSpeed={100}
  name="player"
  // 相机设置
  camListenerTarget="document"
  camCollision={false}
  camInitDis={-0.01}
  camMinDis={-0.01}
  camMaxDis={-0.01}
  camLerpMult={1000}
  camFollowMult={1000}
  camUpLimit={Math.PI / 10}
  camLowLimit={-Math.PI / 10}
  // 移动设置
  mode="CameraBasedMovement"
  disableFollowCam={disable}
  autoBalance={false}
  floatHeight={0}
  ref={rigidRef}
/>`

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Ecctrl component and trace how disableFollowCam affects camera position and player translation during cameraMoveTo. Reproduce the shown sequence with the camera tween, setTranslation call, and disable changing back to false. Done means the camera remains at its new position instead of returning to its earlier position.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.