0 votes

enter image description here

I want simple rotate camera in a skybox center. Just rotation around and toward up or down. Use iphone 7p.

Questions:
1. The code don't work well when look up or look down. Do you have any good solution.
2. If I running the development app without connect xcode. The magnetomater don't work.

here my code:

var angs = []

func _process(delta):
    var acce = Input.get_accelerometer()
#   var gyro = Input.get_gyroscope()
#   var grav = Input.get_gravity()
    var mag = Input.get_magnetometer()

#   rotate_y(mag.x)
#   rotate_x(acce.z)
    mag = mag.normalized()
    acce = acce.normalized()

#   var newang = Vector3(acce.z*.5*PI, -mag.x*2*PI,0)
#   rotation = smooth_value(newang)
#   print(['angavg',angavg])
#   rotation = newang

#   transform.basis = orientate_by_mag_and_grav(mag, grav)
#   transform.basis = orientate_by_mag_and_grav(mag, grav).orthonormalized()

    rotation = Vector3(acce.z*.4*PI,atan2(mag.z,mag.x),0)

;p

in Engine by (35 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.