Skip to content Skip to sidebar Skip to footer

P5 Vector Subraction 'sub' Returning Error

I'm have been trying to upload a p5 sketch onto a react build. Using react-p5-wrapper I am able to successfully render my canvas on the screen however, some vector functions are ca

Solution 1:

According to the author of react-p5-wrapper here in this issue

the p5 that gets passed into the module isn't the same as the global p5 you traditionally get with a script tag. To access certain things with this package (due to the p5 node module itself) you need to use p5.constructor.[something]

Basically use p5.constructor.Vector.sub(this.position, ball.position) in your case.

Post a Comment for "P5 Vector Subraction 'sub' Returning Error"