pmndrs / ecctrl

🕹️ A floating rigibody character controller
MIT License
460 stars 49 forks source link

some time its getting fallingdown and Stuck from map how to respawn the model lot of bug here. #28

Open DevaPandiyan opened 5 months ago

DevaPandiyan commented 5 months ago

`

import { Canvas, useFrame } from '@react-three/fiber' import { Environment, KeyboardControls, OrbitControls } from "@react-three/drei" import { Perf } from 'r3f-perf'; import './App.css' import Light from './Components/Light' import { Map } from './Components/Map' import { Map2 } from './Components/Map2' import { Map4 } from './Components/Map4' import { Map3 } from './Components/Map3' // import { Map } from './Components/Map' import { Physics, RigidBody } from '@react-three/rapier' import { Suspense, useEffect, useRef } from 'react'; import { AnimaCharacterModel } from './Components/AnimaCharacterModel'; import { Avatar } from './Components/Avatar'; import Ecctrl, { EcctrlAnimation, EcctrlJoystick } from 'ecctrl'; import { useConfigurator } from './contexts/Configurator';

function App() {

const { loading, setLoading } = useConfigurator(); const keyboardMap = [ { name: 'forward', keys: ['ArrowUp', 'KeyW'] }, { name: 'backward', keys: ['ArrowDown', 'KeyS'] }, { name: 'leftward', keys: ['ArrowLeft', 'KeyA'] }, { name: 'rightward', keys: ['ArrowRight', 'KeyD'] }, { name: 'jump', keys: ['Space'] }, { name: 'run', keys: ['Shift'] }, { name: 'action1', keys: ['1'] }, { name: 'action2', keys: ['2'] }, { name: 'action3', keys: ['3'] }, { name: 'action4', keys: ['KeyF'] } ]

const characterURL = './AnimatedWoman.glb';

const animationSet = { idle: 'CharacterArmature|Idle', walk: 'CharacterArmature|Walk', run: 'CharacterArmature|Run', jump: 'CharacterArmature|Idle', jumpIdle: 'CharacterArmature|Idle', jumpLand: 'CharacterArmature|Idle', fall: 'CharacterArmature|Idle', // This is for falling from high sky action1: 'CharacterArmature|Wave', action2: 'CharacterArmature|Death', action3: 'CharacterArmature|HitRecieve', action4: 'CharacterArmature|Punch_Left'

}

return ( <>

  <Canvas shadows  >
    {/* <Perf position="top-left"/> */}
    <Environment background files="/night.hdr" />
    <Light />
    <Physics timeStep={"vary"} >
      <KeyboardControls map={keyboardMap}>

        <Suspense fallback={null}>
          {loading === true && (
            <Ecctrl animated position={[0, 10, 0]} >

              <EcctrlAnimation characterURL={characterURL}
                animationSet={animationSet}>
                <Avatar />

              </EcctrlAnimation>

            </Ecctrl>
          )}
        </Suspense>

      </KeyboardControls>
      <RigidBody type="fixed" name="ground">
        <mesh position-y={-5.3} receiveShadow>
          <boxGeometry args={[50, 0.5, 50]} />
          <meshStandardMaterial color="mediumpurple" />
        </mesh>
      </RigidBody>
      {/* <Map4 /> */}
      {/* <Map2 /> */}
      <Map4 />

    </Physics>

    <OrbitControls />

  </Canvas>
</>

) }

export default App

`

https://github.com/pmndrs/ecctrl/assets/25933803/0da24652-f301-43de-8cd1-e04d4294ab23

Map4 here `import React, { useEffect, useRef } from 'react' import { useGLTF } from '@react-three/drei' import { useConfigurator } from '../contexts/Configurator'; import { GLTFLoader } from 'three-stdlib'; import { RigidBody } from '@react-three/rapier';

export function Map4(props) { const { nodes, materials } = useGLTF('/metafactory_booth.glb')

const loader = new GLTFLoader(); const { loading, setLoading } = useConfigurator();

useEffect(()=>{ loader.load( "/metafactory_booth.glb", ( gltf ) => {

      setLoading(true)

  },
  ( xhr ) => {

      // called while loading is progressing
      console.log( `${( xhr.loaded / xhr.total * 100 )}% loaded` );
  },
  ( error ) => {

      // called when loading has errors
      console.error( 'An error happened', error );
  },
  );

});

return (

{/* */}

) }

useGLTF.preload('/metafactory_booth.glb')`

ErdongChen-Andrew commented 5 months ago

Is your map4 wrapped inside < RigidBody > ?

DevaPandiyan commented 5 months ago

yes

ErdongChen-Andrew commented 5 months ago

It seems alright to me. Does it work properly when using just the ground?

DevaPandiyan commented 5 months ago

It seems alright to me. Does it work properly when using just the ground?

yes ground work fine buy get and tried from free map models cant working properly its falling out of the model before loading map or once map is loaded confirmed after get character loading it not working

DevaPandiyan commented 5 months ago

It seems alright to me. Does it work properly when using just the ground?

Only in groundworks fine, Additionally add map its not working again

https://ckk2kc-5173.csb.app/

`import { Canvas, useFrame } from "@react-three/fiber"; import { Environment, KeyboardControls, OrbitControls, } from "@react-three/drei"; import { Perf } from "r3f-perf"; import "./App.css"; import Light from "./Components/Light"; import { Map } from "./Components/Map"; import { Map2 } from "./Components/Map2"; import { Map4 } from "./Components/Map4"; import { Map3 } from "./Components/Map3"; // import { Map } from './Components/Map' import { Physics, RigidBody } from "@react-three/rapier";

import { useConfigurator } from "./contexts/Configurator"; import { Experience } from "./Components/Experience"; import Ecctrl, { EcctrlAnimation, EcctrlJoystick } from "ecctrl"; import { Suspense } from "react"; import { Avatar } from "./Components/Avatar"; import { Playground } from "./Components/Playground"; import { Map5 } from "./Components/Map5";

function App() { const { loading, setLoading } = useConfigurator(); const keyboardMap = [ { name: "forward", keys: ["ArrowUp", "KeyW"] }, { name: "backward", keys: ["ArrowDown", "KeyS"] }, { name: "leftward", keys: ["ArrowLeft", "KeyA"] }, { name: "rightward", keys: ["ArrowRight", "KeyD"] }, { name: "jump", keys: ["Space"] }, { name: "run", keys: ["Shift"] }, { name: "action1", keys: ["1"] }, { name: "action2", keys: ["2"] }, { name: "action3", keys: ["3"] }, { name: "action4", keys: ["KeyF"] }, ];

const characterURL = "./AnimatedWoman.glb";

const animationSet = { idle: "CharacterArmature|Idle", walk: "CharacterArmature|Walk", run: "CharacterArmature|Run", jump: "CharacterArmature|Idle", jumpIdle: "CharacterArmature|Idle", jumpLand: "CharacterArmature|Idle", fall: "CharacterArmature|Idle", // This is for falling from high sky action1: "CharacterArmature|Wave", action2: "CharacterArmature|Death", action3: "CharacterArmature|HitRecieve", action4: "CharacterArmature|Punch_Left", };

return ( <>

  <Canvas shadows>
    {/* <Perf position="top-left"/> */}
    <Environment background files="/night.hdr" />
    <Light />

    <Physics timeStep={"vary"}>
      <KeyboardControls map={keyboardMap}>
        <RigidBody type="fixed" colliders="trimesh">
          <mesh position-y={-3.3} receiveShadow>
            <boxGeometry args={[50, 0.5, 50]} />
            <meshStandardMaterial color="mediumpurple" />
          </mesh>
        </RigidBody>
        {loading === true && (
          <Experience
            characterURL={characterURL}
            animationSet={animationSet}
          />
        )}
      </KeyboardControls>
      <Map4 />
      {/* <Map2 /> */}
      {/* <Map /> */}
    </Physics>

    <OrbitControls />
  </Canvas>
</>

); }

export default App; `

ErdongChen-Andrew commented 5 months ago

Could you set up a simple CodeSandbox? If the ground works there, the issue is likely related to the map setup.

DevaPandiyan commented 5 months ago

Could you set up a simple CodeSandbox? If the ground works there, the issue is likely related to the map setup.

my sandbox account is now free not access to general edit. This is My Mail id devapandiyan19@gmail.com Pls sent it your mail ID ill request to you edit access it...

ErdongChen-Andrew commented 5 months ago

I think you can just creat a public CodeSandbox. I can fork it and make edits, similar to the one I created: https://codesandbox.io/p/sandbox/ecctrl-with-animations-nr4493

DevaPandiyan commented 5 months ago

I think you can just creat a public CodeSandbox. I can fork it and make edits, similar to the one I created: https://codesandbox.io/p/sandbox/ecctrl-with-animations-nr4493

you can try with another map like(above 15 MB to 20 MB) Maps using it some devices it can falling down. in case i loaded the map first after loaded the character im facing same issues

DevaPandiyan commented 5 months ago

icant share sandbox link because general public share isn't free. i can share the zip file. can you make it public sandbox link

here is it https://drive.google.com/file/d/1TtNuybcncKjePDuXvlijaVS54UcI7r_2/view?usp=sharing

pls check it bro

ErdongChen-Andrew commented 5 months ago

How come? I'm using the same free account, and you can make edits on it. If you have a large map, try loading ecctrl once the map is ready

DevaPandiyan commented 5 months ago

**> {loading === true && (

      <Experience
        characterURL={characterURL}
        animationSet={animationSet}
      />
    )} 

**

i m already did it. not work and same issue, 15 Mb map is very below low configuration ecctrl not work perfectly. incase it may be by my mistake, and I shared the whole file in drive pls check the file in my drive. Or atleast give your mail id i request to you in code sandbox

ErdongChen-Andrew commented 5 months ago

https://github.com/pmndrs/ecctrl/assets/84251107/147cb64d-2ebd-417c-9454-d15cc1615206

I tested your map, and it worked perfectly on my end.

DevaPandiyan commented 5 months ago

Wow Amazing . what have you done can you share code . it was help me a lot just show me the code. i have too show the same scenario but the problem is some device make it network related. like once the map loaded after i do it character loading here i face real problem is born. then its not getting perfect. thats why because you show the code i can relate it what is happening what is what pls share and Show me.

https://github.com/pmndrs/ecctrl/assets/25933803/d5749edc-0d0c-4422-be4b-a78382af99cd

and Then

https://github.com/pmndrs/ecctrl/assets/25933803/f02039b6-769e-4a7d-a0f1-ca615fc05759

real problems

https://github.com/pmndrs/ecctrl/assets/25933803/66ad90a3-4e05-4adc-8509-4348be409df1

https://github.com/pmndrs/ecctrl/assets/25933803/5b11796b-e0ac-4604-9c3e-4ef24a9731d9

ErdongChen-Andrew commented 5 months ago

I just used the same code as yours without including the loading process. Unfortunately, I am not able to use that loading method due to too many errors.

DevaPandiyan commented 5 months ago

I just used the same code as yours without including the loading process. Unfortunately, I am not able to use that loading method due to too many errors.

Pls give your Or Demo mail iD request to edit code sandbox .. pls pls Or check it the new file https://drive.google.com/file/d/1pNr8vwST013WXpY_ZwKtV3pioZbkTj3i/view?usp=sharing

campbellgoe commented 2 months ago

Isn't there some way to load the world before loading the falling character?

I'm currently experiencing issues when I load a larger map of models (some instanced). I still fall through the floor it seems because the map is still loading.