Distance between two entities?
BlitzMax Forums/BlitzMax Programming/Distance between two entities?
| ||
Any suggestion to detect the hook of the tractor and the hook of the freight wagon ?, What I want to do is that when it is a certain distance to be able to hook them with each other, but only the hook of each vehicle and not the full wagon in front of vehicle. |
| ||
Is the hook a separate entity from the tractor and wagon? if so, then you can use EntityDistance() on the hooks to find out how far apart they are. If the hooks are part of the tractor and wagon mesh, then you can create a pivot, parent it to the tractor, and position it on the hook. Do the same with the wagon. Then you can use ENtityDistance() with the pivots. |
| ||
Ok, Thanks you TomToad. :) Pivots childs Wagon and Vehicle |
| ||
Problem here. In my thinking logic I would expect that when the hook is brought closer to any load of the load vehicle, the hook of the vehicle will change to red color, once the vehicle hook is chosen, it changes to white. The problem is that it only works with one of the two hooks of the vehicle and not with the two. Any Suggestions? Method enganchar() Local cargos:TCargo = Null For cargos:TCargo = EachIn cargos.lista:TList For Local x:Int = 0 To 1 ' Vehicle Hook and Cargo vehicle hooks If xEntityDistance ( Self.gancho:Int, cargos.ganchos[x:Int] ) <= 2.0 Then xEntityColor ( Self.gancho:Int, 255, 0, 0 ) Else xEntityColor ( Self.gancho:Int, 255, 255, 255 ) End If Next Next End Method |
| ||
Ok, no problem. Okay, what is expected is that when being close to one hook with the other, a visual indicator is activated so that when a key is pressed the vehicles will engage. Method Enganchar() Local cargos:TCargo = Null For cargos:TCargo = EachIn cargos.lista:TList If xEntityDistance (cargos.ganchos[0], Self.gancho:Int ) <= 2.0 Or xEntityDistance (cargos.ganchos[1], Self.gancho:Int ) <= 2.0 Then xShowEntity ( Self.gancho:Int ) Else xHideEntity ( Self.gancho:Int ) End If Next End Method |
| ||
While i can't help you with your problem, i would like to know which 3d solution you are using with Blitzmax? |
| ||
Hi, MikeHart, i am using Xors3D. ;) |
| ||
Thanks for the info |