Quantcast
Channel: Questions in topic: "javascipt"
Viewing all articles
Browse latest Browse all 1875

Move to closest point in front of player with raycast

$
0
0
I have my player, When he lands on the rail I turn on isKinematic and lerp his transform.position to the next point. Now what I would like to do, Is make it so he moves towards the closest point in front of him or the direction he is going. I thought this would be easy, but im finding this extremely difficult. This is what I've thought of so far : 1. create a raycast in front of the player 2. point the raycast to the closest point with tag "point" 3. move player towards raycast direction This is what I have so far if( OnRail == true ){ gameObject.GetComponent(Rigidbody).isKinematic = true; transform.position = Vector3.MoveTowards(transform.position, nearRailPoint.transform.position,Time.deltaTime * force / 3); } I did try to come up with raycast code but nothings working. I am using javascript ( Yes i know, Im awful at learning code ), any help is appreciated thank you!

Viewing all articles
Browse latest Browse all 1875


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>