Unity joy Sphere

// --1 ball jumping ability to control their own code below -2) was added in the Project view to pull the ball to the ball of the Collider materical elastic properties after setting Physical Materical)
SphereCollider sphereCollider;
public bounceSpeed a float;
public Gravity a float;
public a float maxSpeed . 1 =;
a float RADIUS = 0;
a float Speed;
void the Start ()
{
sphereCollider GetComponent = ();
RADIUS = sphereCollider.radius;
}
// drop ball mobile computing
void the drop ()
{
// for each frame by subtracting the simulated gravity with to influence the speed of
speed - = gravity * Time.deltaTime;

// ball limiting maximum achievable speed
Speed = Mathf.Clamp (Speed, -maxSpeed, maxSpeed);
transform.position new new Vector3 + = (0, Speed, 0);
}
void Bounce ()
{
// when the ball rebound when skipping detecting
IF (Speed> = 0)
{
return;
}
// determine the appropriate location of a cube, slightly smaller than the ball, the positional deviation
Vector3 p = transform.position + new Vector3 ( 0, -radius, 0) ;
Vector3 new new Vector3 size = (* RADIUS 0.5f, 0.5f RADIUS *, * RADIUS 0.5f);
. IF (Physics.OverlapBox (P, size, Quaternion.identity, LayerMask.GetMask ( "Ground")) the Length> 0 )
{
Speed = bounceSpeed;
}
}
void the Update ()
{
Bounce ();
the Drop ();
}
. 1
2
. 3
. 4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
}

//物体的旋转
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

InputLogic class public: {MonoBehaviour
// recording position of a mouse
Vector3 lastMousePos = Vector3.zero;
void TouchRotate ()
{
        rotated // press the left mouse button
        IF (Input.GetMouseButton (0))
{
            // This is calculated and a mouse position on a difference, then the Y-axis rotation of
            a float Movex = (Input.mousePosition - lastMousePos) .x;
transform.Rotate (0, -moveX, 0);
}
}
void the Update ()
{
TouchRotate (http://www.amjmh.com/v/BIBRGZ_558768/);
lastMousePos = Input.mousePosition;
}
}

Guess you like

Origin www.cnblogs.com/hyhy904/p/11460268.html