Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | unnamed81 |
issue Solved!
Epidal as the Answer.
I’m trying to draw a line with ImmediateGeometry from the origin of the im node(or the player node or raycast node, there all in the same position) to the collision point of the raycast, the line draws fine, but when the player is rotated the line seems to rotate twice as much as the player does, so for a 360 rotation of the player the line will have rotated 720
just ignore that small line coming out from the ball thats the balls raycast.
heres the code im using to draw the line
func get_preview_path():
var raycast = self
var im = $ImmediateGeometry
var normal
var start = im.transform.origin
var collision_point
if raycast.is_colliding():
im.clear()
normal = get_collision_normal()
collision_point = get_collision_point()
im.begin(1,null)
im.set_color(Color(1,1,1,1))
im.set_normal(Vector3(0,-1,0))
im.add_vertex(start)
im.set_color(Color(1,1,1,1))
im.set_normal(Vector3(0,-1,0))
im.add_vertex(collision_point)
im.end()
the get_preview_path func is called from the player.gd in the player rotation func
func player_rotate():
var rotate_strength = 0.1
var left = Input.is_action_pressed("player_rot_left")
var right = Input.is_action_pressed("player_rot_right")
if left:
self.rotation_degrees.y += rotate_strength
Global.Ball.rotation_degrees.y += rotate_strength
$RayCast.get_preview_path()
elif right:
self.rotation_degrees.y -= rotate_strength
Global.Ball.rotation_degrees.y -= rotate_strength
$RayCast.get_preview_path()
im pretty sure PI radians plays a part here, but i have no idea…
if anyone could point me in the right direction, i would be very much appreciative.