Hello.<br />Ok first things first, what I trying to do is to make some kind of navigation (I used same in unity and worked well) for my space ship. I trying to use collision shape to get point where mouse button is clicked in 3D space to rotate ship, this collision shape is moving with camera (is Camera's child). Its working but if ship stays idle and not moving, but when ship starts flying its messed up.<br />Original post can be <a href=http://godotengine.org/qa/2934/help-to-fix-script-please>found here</a>. I asking on this forum to increase chances to get help, trying to solve this 4 or 5 days now, but no luck so far.</br><br /> So here is the problem: to understand what I talking about <a href=<a rel="nofollow" target="_blank"><img width="640" alt="" height="385" title="Image: null"></a> check</a><br /><br />
<br />When I start game and ship not moving everything looks fine, where mouse button is pressed there appears white sphere but when ship starts moving white sphere appears not in same point where mouse is clicked, just look at the video at first looks fine, later looks like collision box getting smaller, probably miss calculations. <br />in case here is <a href=https://www.dropbox.com/s/mcpdcolrv9hznxw/space_game.7z?dl=0>my project</a><br /><br />I know someone said something wrong with local and global positioning, but I cant figured out what or where is mistake. Here is raycast and rotation code:<br /><br />
<br />func cast():<br />&nbsp; var mouse_pos = get_viewport().get_mouse_pos()<br />&nbsp; ray_from = cam.project_ray_origin(mouse_pos)<br />&nbsp; ray_to = ray_from + cam.project_ray_normal(mouse_pos)
ray_length<br /><br />&nbsp; var directState = PhysicsServer.space_get_direct_state(cam.get_world().get_space())<br />&nbsp; var collisions = directState.intersect_ray(ray_from, ray_to, [self])<br /><br />&nbsp; if collisions.size() and !collisions.empty() and collisions[&quot;collider&quot;].get_name() == &quot;nav&quot;:<br /><br /><br />&nbsp; &nbsp; col_pos = collisions.position<br />&nbsp; &nbsp; var t = get_node(&quot;ship&quot;).get_transform()<br />&nbsp; &nbsp; col = col_pos - t.origin<br />&nbsp; &nbsp; #print(&quot;collided with: &quot;, collisions[&quot;collider&quot;].get_name(), &quot; distance &quot;, ship.get_rotation().distance_to(col), &quot; ___ &quot;)<br /> else:<br />&nbsp; &nbsp; print(&quot;something went wrong --&gt; NO COLLISIONS DETECTED!&quot;)<br /><br />func shipRotation(delta):<br />&nbsp; var t = get_node(&quot;ship&quot;).get_transform()<br />&nbsp; var rotA = get_node(&quot;ship&quot;).get_rotation()<br />&nbsp; var lookDir = col - t.origin<br />&nbsp; var rotTrans = t.looking_at(lookDir, Vector3(0,1,0))<br />&nbsp; var thisRot = Quat(t.basis).slerpni(rotTrans.basis, currentRotSp delta)<br />&nbsp; if currentRotSp &gt; global.shipRotSp:<br />&nbsp; &nbsp; currentRotSp = global.shipRotSp<br />&nbsp; get_node(&quot;ship&quot;).set_transform(Transform(thisRot, t.origin))<br />&nbsp; var rotB = get_node(&quot;ship&quot;).get_rotation()<br /><br />&nbsp; if rotA == rotB:<br />&nbsp; &nbsp; enableRot = false<br />&nbsp; &nbsp; col = null<br />
<br /><img alt="YfAHcTdjpg" src="http://i.imgur.com/YfAHcTd.jpg" title="Image: http://i.imgur.com/YfAHcTd.jpg"><br /><br />Please help me to fix this problem, because can't do anything till this problem exist.<br />Thank you!