-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New version of react and react-native does not work with Matter-js #53
Comments
Can you show your code? I'm using Matter with React 16.11.0 and RN0.62.2. Gravity is working for me. |
Physics.js const Physics = (entities, { touches, time }) => { export default Physics;` and app here
}` |
Have you tried to set just the y-gravity? The x-gravity defaults to 0 so you can skip that. Also what does this do in Physics.js? Can you try to comment out this line and see if it works? |
Hi @sovanminea - can you show us your code for the |
hi @bberak here it is
} |
Hmmm that looks okay.. As @yuenlye mentioned - have you tried uncommenting this line:
Also, maybe try give the dinosaur body a As a last resort, you can try create a snack of your app - that will help us debug (but do this last). |
Hi @sovanminea, Could this be a similar issue to: #56 (comment) A quick way to test this would be to extend Dinosaur from |
hey, i use same problem, its indeed rendering problem i think, since i log the body position and its changing, but whatever i've done it seems its to no avail, is there any example to use the setState for this case?, since i automatically move the object from system rather than controlling it with button or something |
@Solid-Metal Don't really have the exact solution, but you can check out my code skeleton. I used the accelerometer to update the x position of a body. Or you can try to dispatch an event in system and update the body position in the event handler? |
Hey @Solid-Metal, Can you share your renderer code? |
hey sorry for the late reply, heres my renderer
|
Hmm @Solid-Metal, That looks fine - you're extending Can you try change Claw to a functional component: function Claw(props) {
const x = props.position[0];
const y = props.position[1];
return (
<View style={[styles.claw, { left: x * props.size, top: y * props.size }]}>
<Image source={require('../../assets/images/gamification/crane.png')}/>
</View>
);
}
export { Claw }; |
hey @bberak just trying it out, and it didnt work, still same problem, the matterjs physics body itself is moving, but not the image, even if i forcefully to moving it out using the position it just updating that renderer but not the physics is there any chance it cause by the styling here |
Hmmm @Solid-Metal, How come you are multiplying x and y by props.size? Can you try and add this to your function/render method to see the values:
Also, I've got a similar example in the handbook project that might be useful to compare with: https://github.com/bberak/react-native-game-engine-handbook/blob/master/app/physics/rigid-bodies/renderers.js |
sorry for late reply yeah, i'm an idiot lol, i didn't pay attention to your handbook renderer function, i forgot to put the transform and rotation to the sprite, it now works well ! |
Awesome @Solid-Metal - glad you got it working 👍 |
I follow the instruction and configure with matter js to test gravity but it does not work.
The text was updated successfully, but these errors were encountered: