当我将disableFollowCam从新设置为false时,这时候相机会突然回到之前disableFollowCam设置为true时的位置,即使我在相机移动时已经将人物的位置设置到新的位置。
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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