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. # xoseca78

Member

54

0 Neutral

• Rank
Member

## Profile Information

• Gender
Male
• Location:
1x
1. ## The Player ball with the Superspeed

With this superspeed script the player ball with the superspeed goes in the wrong direction, I want that the superspeed must make go the ball forward where the camera is , how i can fix this script ? ----------------- // speed of the ball var speed = 5.0; var superspeed = 10.0; var radius = 1.0; private var velocity : Vector3 = Vector3.zero; function Start(){ transform.localScale = Vector3.one * radius * 2; var hit : RaycastHit; if(Physics.Linecast(transform.position, transform.position - Vector3.up * 500, hit)){ transform.position = hit.point + Vector3.up * radius; } // add a rigidbody if we dont have one. if(!rigidbody) gameObject.AddComponent(Rigidbody); // set the mass according to the radius. rigidbody.mass = 50 * radius; } function FixedUpdate () { // let see if our body is on the ground. { speed = 5.0; } var hit : RaycastHit; var isGrounded = Physics.Raycast(transform.position, -Vector3.up, hit, radius * 1.5); // base movement off of the camera, not the object. // reset the camera's X to zero, so that it is always looking horizontally. var x = Camera.main.transform.localEulerAngles.x; Camera.main.transform.localEulerAngles.x = 0; // now collect the movement stuff This is generic direction. var direction = Vector3(Input.GetAxis("Horizontal"),0,Input.GetAxis("Vertical")); // prevent the ball from moving faster diagnally if(direction.magnitude > 1.0) direction.Normalize(); // If we are grounded, then lets see if we want to jump. if(isGrounded && Input.GetKeyDown(KeyCode.Space)) { speed = superspeed; rigidbody.AddForce(transform.forward * rigidbody.mass * 50, ForceMode.Impulse); } // if we arent pressing anything, dont mess with the physics. if(direction.magnitude > 0){ // convert isGrounded into something we can use var modifier = isGrounded ? 3.0 : 0.5; // lets set the direction according to the camera now. direction = Camera.main.transform.TransformDirection(direction) * speed * 2; // lets take the downward velocity from the current so that we dont get wierd physics results direction.y = rigidbody.velocity.y; // Now, lets keep track of a velocity. // This will let the ball move while we are not pressing anything. rigidbody.velocity = Vector3.Lerp(rigidbody.velocity, direction, modifier * Time.deltaTime); // Now, lets break the rotation out from the movement. var rotation = Vector3(rigidbody.velocity.z,0,-rigidbody.velocity.x) * 20; // Lets add some spin to make the ball move better rigidbody.angularVelocity = Vector3.Lerp(rigidbody.angularVelocity, rotation, modifier * Time.deltaTime); } // return the camera's x rotation. Camera.main.transform.localEulerAngles.x = x; }
2. I want to create a ball player superspeed but do not work well the script
3. OOOOOOOOOOOOOOOO
4. in the AddForce Which Direction variable can i use ?
5. ## After that the cube is dropped must return to the starting position

I'm trying to create a game similar to Crash Bandicoot , where there are objects that fall just goes over an object after 5 seconds
6. ## After that the cube is dropped must return to the starting position

Thanks LynoHD works perfectly your script for me
7. ## After that the cube is dropped must return to the starting position

But I want that the cube must return to its starting position only after 5 seconds
8. ## After that the cube is dropped must return to the starting position

Here X -22.333 Y 25.863 Z 324.38
9. ## After that the cube is dropped must return to the starting position

using UnityEngine; using System.Collections; public class DeleteMe : MonoBehaviour { [SerializeField] private Rigidbody m_ObjectToFall; void Start() { m_ObjectToFall.isKinematic = true; m_ObjectToFall.useGravity = false; } void OnTriggerEnter() { StartCoroutine(Fall()); } private IEnumerator Fall() { yield return new WaitForSeconds(5f); m_ObjectToFall.isKinematic = false; m_ObjectToFall.useGravity = true; } } I want that after the cube is dropped due to the passage of the character player on the cube , the cube must return to the starting position , how do I do this ?
10. Your scripts work for me now
11. But I should add the gravity to the rigidbody in the land cube ?
12. this script does not work for me
13. But the land fly up instead of falling , I do not understand why
14. I'm trying it
15. Yes but the land must fall after 5 seconds
×
×
• Create New...