Quantcast
Channel: Questions in topic: "measure"
Viewing all articles
Browse latest Browse all 91

measure to an axis

$
0
0
I have got a glider and i have got a thermal, wich in my case is just a cylinder with an capsule colider wich triggers an upward force. What i want to do now is that, when the glider comes more centric, the upward force becomes also more. So I have to measure the distance to the center of my cylindrical thermal. I convertet my 2 Vetor3 to a vector2 for topview calculating. Picture: V3.distance (gives me the distance to the center of the object) V2.distance (gives me the distance to the center axe of the cylinder( y becomes z in vector2)) In this case it works like I expected. But later on I want to add some windspeed wich affects the glider and also the thermal. So in this case the thermal will not be exactly on y axis anymore. it will be in between 90 and 45 degree compared to the horizont depending on the wind. So in this case my actual Script will not work here and i have to measure the distance to the center cylindrical axis. Any Idea how I can do that? ![alt text][1] [1]: /storage/temp/46412-thermal.png public float ThermalStrength; public GameObject Wing_Center_GO; private float ThermalDamp; private Rigidbody Wing_Center_RigidBody; // Use this for initialization void Start () { Wing_Center_RigidBody = Wing_Center_GO.GetComponent (); } void OnTriggerStay(Collider col){ //var distance = Vector3.Distance(transform.position, Wing_Center_GO.transform.position); Vector2 PilotV2; Vector2 ThermikCenterV2; float distance; // Vector3 to Vector2 conversion from Topview PilotV2 = new Vector2(Wing_Center_GO.transform.position.x, Wing_Center_GO.transform.position.z); ThermikCenterV2 = new Vector2 (transform.position.x, transform.position.z); // get distance from Thermal center distance = Vector2.Distance (PilotV2, ThermikCenterV2); ThermalDamp = distance * 0.1f; Wing_Center_RigidBody.AddForce (Vector3.up * (ThermalStrength - ThermalDamp)); }

Viewing all articles
Browse latest Browse all 91

Trending Articles



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