Hello world, hm, i try to make an application for Android. The export work and i can move my head to look around me. But i can't "move forward" in my map.
It's for my smartphone, and i have "only" my phone (no joystick or something else). So, i thought "ok it will be cool if in my map i had a "special object", and it "tract me" if i look a this object. I thought use a Raycast to do it. My player is so :
Player +-- Head +-- ARVROrigin +-- ARVRCamera +-- deFrag(Raycast)
On PC : when i move my mouse and there a collision with the wall or orange box or floor, i move forward. When i look at the sky, i stop.
On my smartphone, when i change the angle of my smartphone and i look at the wall, or orange box or floor, i move... to the right. When i look at the sky, i stop.
It's in progress but, i am blocked to this problem. I would like to move "only" when i look at the orange box, and go "to" the orange box. And stop when i look at another thing... (and so, with a lot of orangebox, i could move everywhere in the map ;D)
Have you any idea please? Maybe i can use "look_at" but i don't understand to do it... x/
Thanks for your advice :)
ps: here is a picture of the map, and the player.gd
` extends KinematicBody
var speed
var default_move_speed = 1.5
var acceleration = 20
var gravity = 0.2
var mouse_sensivity = 0.1
var direction = Vector3()
var velocity = Vector3()
var fall = Vector3()
onready var head = $Head
onready var anim_play = $Head/HB
onready var raycast_pk = $"Head/ARVROrigin/ARVRCamera/deFrag"
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
func _input(event):
if event is InputEventMouseMotion:
rotate_y(deg2rad(-event.relative.x * mouse_sensivity))
head.rotate_x(deg2rad(-event.relative.y * mouse_sensivity))
head.rotation.x = clamp(head.rotation.x, deg2rad(-90), deg2rad(90))
func _process(delta):
speed = default_move_speed
direction = Vector3()
if raycast_pk.is_colliding():
direction -= transform.basis.z
direction = direction.normalized()
velocity = velocity.linear_interpolate(direction * speed, acceleration * delta)
velocity = move_and_slide(velocity, Vector3.UP)
if not is_on_floor():
fall.y -= gravity + delta
if direction != Vector3():
anim_play.play("HB_marche")
$"Pas/Bruit2pas".play("marche")
move_and_slide(fall, Vector3.UP)
func _on_Bruit2pas_finished(anim_name):
if is_on_floor():
var aupif = str(randi() % 3)
if aupif == String("0"):
$"Pas/pl_step1".play()
if aupif == String("1"):
$"Pas/pl_step2".play()
if aupif == String("2"):
$"Pas/pl_step3".play()
if aupif == String("3"):
$"Pas/pl_step4".play()
`