Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

Aeleas

Member
  • Content count

    80
  • Joined

  • Last visited

Community Reputation

1 Neutral

About Aeleas

  • Rank
    Member

Profile Information

  • Gender
    Male
  • Location:
    this world

Recent Profile Visitors

410 profile views
  1. Tank head rotate angle ?

    Thank you guys for your help. I really appreciate it. Now, I or We solved the rotation problem of the tank head. and script works fine. But new issue show-up. I added new script to moving tank by arrows. I found the head not aiming the target when turn tank around !! This new script i added on "prototype_Tank" object. using UnityEngine; using System.Collections; public class RearWheelDrive : MonoBehaviour { private WheelCollider[] wheels; public float maxAngle = 30; public float maxTorque = 300; public GameObject wheelShape; // here we find all the WheelColliders down in the hierarchy public void Start() { wheels = GetComponentsInChildren<WheelCollider>(); for (int i = 0; i < wheels.Length; ++i) { var wheel = wheels [i]; // create wheel shapes only when needed if (wheelShape != null) { var ws = GameObject.Instantiate (wheelShape); ws.transform.parent = wheel.transform; } } } // this is a really simple approach to updating wheels // here we simulate a rear wheel drive car and assume that the car is perfectly symmetric at local zero // this helps us to figure our which wheels are front ones and which are rear public void Update() { float angle = maxAngle * Input.GetAxis("Horizontal"); float torque = maxTorque * Input.GetAxis("Vertical"); foreach (WheelCollider wheel in wheels) { // a simple car where front wheels steer while rear ones drive if (wheel.transform.localPosition.z > 0) wheel.steerAngle = angle; if (wheel.transform.localPosition.z < 0) wheel.motorTorque = torque; // update visual wheels if any if (wheelShape) { Quaternion q; Vector3 p; wheel.GetWorldPose (out p, out q); // assume that the only child of the wheelcollider is the wheel shape Transform shapeTransform = wheel.transform.GetChild (0); shapeTransform.position = p; shapeTransform.rotation = q; } } } } Game Link https://www.sendspace.com/file/4nnj07 How to solve this issue ?
  2. Tank head rotate angle ?

    I did what you said. But the head rotate to opposite side ! var rotation = Quaternion.LookRotation(target.position - transform.position); transform.localRotation = Quaternion.Slerp(transform.localRotation, rotation, Time.deltaTime * 2); rotation = Quaternion.Euler(0, rotation.eulerAngles.y, 0); transform.localRotation = Quaternion.Euler(0, transform.localRotation.eulerAngles.y, 0);
  3. Tank head rotate angle ?

    Hi guys I have issue that bring me a headache . the head of this tank rotate to aim at the target but it get out from the body of the tank !! I locked the X & Z angles but it doesn't work correctly ! This always happen when moving the tank up or down. It should be like this here is my script: public Transform target; public float h_x; // Update is called once per frame void Update () { var rotation = Quaternion.LookRotation(target.position - transform.position); transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * 2); rotation = Quaternion.Euler(0, rotation.eulerAngles.y, 0); transform.rotation = Quaternion.Euler(0, transform.rotation.eulerAngles.y, 0); } file link https://www.sendspace.com/file/ssgvys I really need to solve this problem. HELP ME GUYS
  4. wheels facing wrong side ?

    thank you for your tries. It doesn't work. But I found a solution to put the wheel inside Empty-Object then correct the angle.
  5. wheels facing wrong side ?

    here are two more images. the wheel on the front is an example for the correct direction of the wheel. Now on play mode. I think you can see the problem. You are right about the scale but i need first to rotate the wheel
  6. wheels facing wrong side ?

    you right. but in my case will not work. https://s1.postimg.org/lwijtf3an/1.5-_UV-_Test-_Grid.png I need to rotate this object.
  7. wheels facing wrong side ?

    Hi I'm working on tank wheels. my problem that wheels facing wrong side. Here is the script i used. what i need is to rotate every wheel on Y angle only to fix the rotation. using UnityEngine; using System.Collections; public class RearWheelDrive : MonoBehaviour { public WheelCollider[] wheels; public float maxAngle = 30; public float maxTorque = 300; public GameObject wheelShape; // here we find all the WheelColliders down in the hierarchy public void Start() { wheels = GetComponentsInChildren<WheelCollider>(); for (int i = 0; i < wheels.Length; ++i) { var wheel = wheels [i]; // create wheel shapes only when needed if (wheelShape != null) { var ws = GameObject.Instantiate (wheelShape); ws.transform.parent = wheel.transform; } } } // this is a really simple approach to updating wheels // here we simulate a rear wheel drive car and assume that the car is perfectly symmetric at local zero // this helps us to figure our which wheels are front ones and which are rear public void Update() { float angle = maxAngle * Input.GetAxis("Horizontal"); float torque = maxTorque * Input.GetAxis("Vertical"); foreach (WheelCollider wheel in wheels) { // a simple car where front wheels steer while rear ones drive if (wheel.transform.localPosition.z > 0) wheel.steerAngle = angle; if (wheel.transform.localPosition.z < 0) wheel.motorTorque = torque; // update visual wheels if any if (wheelShape) { Quaternion q; Vector3 p; wheel.GetWorldPose (out p, out q); // assume that the only child of the wheelcollider is the wheel shape Transform shapeTransform = wheel.transform.GetChild (0); shapeTransform.position = p; shapeTransform.rotation = q; } } } }
  8. Car drifting ?

    Better than nothing. Thank you Ocular.
  9. Car drifting ?

    OK. How to solve it ? Before i used "rb.AddForce". Yes, car is drifting but not that good. if I increased the speed I get nice long slide/drift but this mean i can't hit my target easily. rb.AddForce(gameObject.transform.forward * 500 * Time.deltaTime); red line is the car movement to hit target.
  10. Car drifting ?

    Hi Guys These days I'm working on car project. I could make it moving and turning with camera very well. but it doesn't give me a scene of realty. So, I search for a tutorial explain the sliding/drifting of a car. I didn't find any one for 3d project except one for 2D games. I copied the script file and transfer it to 3D. But got error. and i don't know if this will work or not . here is the script: float speed = 30f; float torqueForce = 200f; float DriftFactorSticky = 0.9f; float DriftFactorStippy = 1.0f; float maxStickyVelocity = 2.5f; float minSlippyVelocity = 1.5f; // Use this for initialization void Start () { } // end start // Update is called once per frame void Update () { }// end update void FixedUpdate() { Rigidbody rb = GetComponent<Rigidbody>(); float driftFactor = DriftFactorSticky; if (RightVelocity().magnitude > maxStickyVelocity) { driftFactor = DriftFactorStippy; } rb.velocity = forwardVelocity() + RightVelocity() * driftFactor; if (Input.GetKeyDown(KeyCode.Y)) { rb.AddForce(transform.forward * speed); } if (Input.GetKeyDown(KeyCode.U)) { rb.AddForce(transform.forward * -speed /2); } float tf = Mathf.Lerp(0, torqueForce, rb.velocity.magnitude / 2); rb.angularVelocity = Input.GetAxis("Horizontal") * tf; // Cannot implicitly convert type `float' to `UnityEngine.Vector3 } // end fixed Vector3 forwardVelocity() { return transform.forward * Vector3.Dot (GetComponent<Rigidbody>().velocity, transform.forward); } Vector3 RightVelocity() { return transform.right * Vector3.Dot (GetComponent<Rigidbody>().velocity, transform.right); } If you have any other option please write it.
  11. Problem with the angles of robot ?

    Thank you for your help.
  12. Problem with the angles of robot ?

    Yes. this is good. but new thing come u. Now when this robot comes down from the hill he keeps looking down and walking like that. what I have to do to let him look straight ?
  13. Problem with the angles of robot ?

    It should work but it doesn't. it gives me this error // Cannot modify the return value of 'UnityEngine.Transform.rotation' because it is not a variable. //
  14. Problem with the angles of robot ?

    I tried all these and no one works. gameObject.transform.eulerAngles.y = ManFace.transform.eulerAngles.y; gameObject.transform.localRotation.eulerAngles.y = ManFace.transform.localRotation.eulerAngles.y; gameObject.transform.eulerAngles.y = ManFace.transform.eulerAngles.y; gameObject.transform.rotation.eulerAngles.y = ManFace.transform.rotation.eulerAngles.y; gameObject.transform.rotation.y = ManFace.transform.rotation.y;
  15. Problem with the angles of robot ?

    My problem is that when I post this script to my robot, I found that when he moves on a hill or anything above ground, he can't rotate his angle to moves with the ground under him. that's because the "ManFace" object rotate only right and left. public Transform ManFace; public float f_MoveSpeed = 2.0f; // Update is called once per frame void Update () { gameobject.transform.rotation = ManFace.transform.rotation; // here is my problem transform.position += ManFace.transform.forward * f_MoveSpeed * Time.deltaTime; } What i need is to let the "Manface" effect on right and left sides of robot only, other angles are free.
×