0

I've been using this react three fiber minecraft example:

https://codesandbox.io/s/vkgi6?file=/src/Player.js:1228-1312

As a base for player movements..

frontVector.set(0, 0, backward - forward)
sideVector.set(left - right, 0, 0)

These lines control the movement, with set taking x,y,z parameters.

backward and forward are taken from:

import { useKeyboardControls } from "@react-three/drei"
const [, get] = useKeyboardControls()
const { forward, backward, left, right, jump } = get()

In Drei 9.34.4 (which the example uses), backward, forward, left, right are console logged as boolean values, but upgrading drei to ^9.53.3 expects a number. I've tried converting them to numbers using frontVector.set(0, 0, +backward - +forward), but the player still won't move.

Any ideas on how to convert this to work with Drei ^9.53.3?

As a bonus answer, I'd be interested in figuring out how to control the player position using simulated keyboard presses, if anyone has an idea on this (to make mobile controls).

Thanks!

timhc22
  • 7,213
  • 8
  • 48
  • 66

0 Answers0