Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Temez1 |
Hey!
I’m trying to do a top-down mini golf game to learn the Godot engine. So the question is that how to rotate KinematicBody precisely so that it collides the ball every time. Now it collides only when the rotation speed is low enough. With higher speeds, it goes through.
If I understand the physics engine right it doesn’t recognize the collision because the stick clips inside the ball between frames. So the question is how this should be done? I didn’t figure out how move_and_collide()
would help me in this situation because I’m not moving the stick. I’m just rotating it so it can hit the ball. Here’s a pic from the side angle if it helps
And here is the current code. I tried to do the same with rotate_object_local()
without success.
extends KinematicBody
const LOOKAROUND_SPEED = 0.01
var mousePos = Vector2()
func _physics_process(delta):
rotate_z(mousePos.x*LOOKAROUND_SPEED)
rotate_x(-mousePos.y*LOOKAROUND_SPEED)
mousePos = Vector2()
transform = transform.orthonormalized()
func _input(event):
if event is InputEventMouseMotion:
mousePos = event.relative