Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Okan Ozdemir |
Please be helpful my code is a add_force 'd rigid body. my camera doesn’t rotate around it
func _input(event):
if event is InputEventMouseMotion and event.button_mask & 1:
# modify accumulated mouse rotation
rot_x += event.relative.x * .0001
# rot_y += event.relative.y * .01 * PI
transform.basis = Basis() # reset rotation
rotate_object_local(Vector3(0, 1, 0), rot_x) # first rotate in Y
# get_parent().rotate_object_local(Vector3(1, 0, 0), rot_y) # then rotate in X
I Have made the hyrarchy as follows:
-Rigidbody
–3dposition
—camera
camera script (set_as_toplevel(true) is set to true because my cube which is a 3D rigid body can rotate around, but my camera not):
extends Camera
onready var t1 = get_parent().get_node("RigidBall") #just a meshinstance
func _ready():
set_as_toplevel(true)
func _process(delta):
# get_parent().rotate(Vector3(0,0,-10).normalized(), .01)
pass
var rot_x = 0
func _physics_process(delta):
rot_x *= .001
rotate_object_local(Vector3(0, 1, 0), .01)
# get_parent().rotation_degrees.y += 10
# transform.basis = Basis()
# look_at(get_parent().transform.origin, Vector3(0,0,1))
# get_parent().transform.origin = Basis()
# get_parent().transform.basis = Basis()
pass
## get_parent().get_node("RigidBall").global_transform.basis.x * -1
## rotate_object_local(Vector3(0,1,0), deg2rad(10))
## rot_x += 30
## transform.basis = Basis()
## rotate_object_local(Vector3(0, 1, 0), rot_x)
#
#
## get_parent().get_node("RigidBall").transform.origin.y
## rotate_y(deg2rad(1))
# rot_x += .01
# transform.basis = Basis()
## rotate_object_local(Vector3(0, 1, 0), rot_x)
# rotate_object_local(Vector3(0, 1, 0),rot_x)
##var rot_x = 0
#var rot_y = 0
#
#func _input(event):
# if event is InputEventMouseMotion and event.button_mask & 1:
# # modify accumulated mouse rotation
# rot_x += event.relative.x * .01 * PI
# rot_y += event.relative.y * .01 * PI
# transform.basis = Basis() # reset rotation
# get_parent().rotate_object_local(Vector3(0, 1, 0), rot_x) # first rotate in Y
# get_parent().rotate_object_local(Vector3(1, 0, 0), rot_y) # then rotate in X
Lookatfromposition() also is problem
Okan Ozdemir | 2020-04-10 21:24