Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
0
Members

Move Actor Based On Its Orientation With applyLocalImpulse()?

A topic by neat things created Oct 27, 2016 Views: 511
Viewing posts 1 to 1

Hey all!


So, here's the deal: I'm working in 3D and I want to make an actor move based on where it's facing. So hitting the 'W' key should move the character towards where they are 'looking' at [ using physics, btw, got a cannon-body hooked up to the character ].

I've tried a few methods, but the simplest seems to be:

this.actor.cannonBody.body.applyLocalImpulse( new CANNON.Vec3( 0, 0, -1 ), new CANNON.Vec3( 0, 0, 0 ) );

Now, while this does work, I'm very new to 3D programming, confused about physics, and bad at math haha. So I was wondering if this is the best way to go about it, or is there a simpler / possibly less resource-intensive [ not that I notice `applyLocalImpulse()` to be all that bad ] way of going about things?


If you have experience with this kind of stuff, please let me know! And share any and all knowledge you have on the topic as I'm trying to consume all the information I can in an effort to learn. Thanks a ton! :)