YouGroove Posted February 15, 2014 Share Posted February 15, 2014 I have two 3D points in space : - begin - end I want to move bullet using collision with PhysicsSetPosition(x,y,z, force) from start 3D position to end 3D position. And for example moving 0.2 step eahc step with that vector. How to code that with maths ? Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Guppy Posted February 15, 2014 Share Posted February 15, 2014 Since the two positions can be thought og as vectors from origo: Normalize(A-B)*0.2 Quote System: Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k Link to comment Share on other sites More sharing options...
YouGroove Posted February 15, 2014 Author Share Posted February 15, 2014 ok great. So in Lua i do C.x = A.x - B.x C.y = A.y - B.y C.z = A.z - B.z C.normalize() * 0.2 Thanks Guppy. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
YouGroove Posted February 15, 2014 Author Share Posted February 15, 2014 Didn't worked so well. If someone have Lua code i'm interested. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Guppy Posted February 15, 2014 Share Posted February 15, 2014 Maybe you have it the wrong way round? In that case every step when you multiply c by step you would have the bullet flying in the wrong direction. if that's not the issue I'm going to need some more details Quote System: Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k Link to comment Share on other sites More sharing options...
YouGroove Posted February 15, 2014 Author Share Posted February 15, 2014 I have done B-A But i got Normalize or Transform:Normal() Well let's wait for some super math coder to give the Lua code response. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
YouGroove Posted February 15, 2014 Author Share Posted February 15, 2014 Yep, i find same explication , it should work. http://xnafan.net/2012/12/pointing-and-moving-towards-a-target-in-xna-2d/ Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.