YouGroove Posted March 3, 2013 Posted March 3, 2013 I would want to check distance between player and goblin with a simple Cylinder check. Does some people knwo how to do that in Lua : If a point is inside a 2D circle (the point is the barbarian origin, the owner of the circle center is the goblin) I'll do simple bouding box check also : a point inside a box volume. I find these way of doing lot more simple than the AABB stuff i seen in GoblinAI , even with good explanation i dunderstand , but why calling that when you can just makeit simple ? Perhaps it is same in terms of speed ? Another point of optimisation is to check distance only each 5 or 15 frames, it's not a simulation game. Quote Stop toying and make games
Canardia Posted March 3, 2013 Posted March 3, 2013 Distance is calculated by simply getting the squareroot of the sum of the squared differences of 2 entity's positions: distance = sqrt( ((p2.x-p1.x)*(p2.x-p1.x)) + ((p2.y-p1.y)*(p2.y-p1.y)) + ((p2.z-p1.z)*(p2.z-p1.z)) ) http://en.wikipedia.org/wiki/Euclidean_distance Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■
cassius Posted March 3, 2013 Posted March 3, 2013 Could someone show us an EntityDistance function ( in code) lua or c++ Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++
Rastar Posted March 3, 2013 Posted March 3, 2013 Josh was mentioning something here: http://www.leadwerks.com/werkspace/topic/5987-le-3-question/#entry51770 1 Quote
Canardia Posted March 3, 2013 Posted March 3, 2013 Could someone show us an EntityDistance function ( in code) lua or c++ The code I posted is the entitydistance. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■
YouGroove Posted March 3, 2013 Author Posted March 3, 2013 Great , DistanceToPoint will do it. thanks Quote Stop toying and make games
cassius Posted March 3, 2013 Posted March 3, 2013 distance = sqrt( ((p2.x-p1.x)*(p2.x-p1.x)) + ((p2.y-p1.y)*(p2.y-p1.y)) + ((p2.z-p1.z)*(p2.z-p1.z)) ) How would I relate this code to Entity_1 Entity_2? Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++
Josh Posted March 3, 2013 Posted March 3, 2013 C++ Vec3 position = entity->GetPosition(true); float dist = position.DistanceToPoint(otherentity->GetPosition(true)); Lua: local position = entity:GetPosition(true) local dist = position:DistanceToPoint( otherentity:GetPosition(true) ) Quote My job is to make tools you love, with the features you want, and performance you can't live without.
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.