# pragma strict
Var newobject: Transform;
Var tempPosition: Vector3;
Var: float;
Var vy: float;
Var a: float;
Var b: float;
The function Start () {
TempPosition. X=5;
TempPosition. Y=10;
TempPosition. Z=0;
Vy=0;
Vx=5;
A=0;
B=- 10;
}
The function Update () {
If (Input. GetButtonDown (" Fire1 ")) {
Var n: Transform=Instantiate (newobject, Vector3,10,0 (5), the Transform, rotation); }
ReflashPosition ();
The transform. The position. X=tempPosition. X;
The transform. The position. Y=tempPosition. Y;
}
The function reflashPosition () {
TempPosition. X=vx * Time. DeltaTime + 0.5 * a * Mathf Pow (Time deltaTime, 2);
Vx=ag + a * Time. DeltaTime;
TempPosition. Y=vy * Time. DeltaTime + 0.5 * b * Mathf Pow (Time deltaTime, 2);
Vy vy +=b * Time. DeltaTime;
}
CodePudding user response:
First of all, I think you can use an iterative formula, reflashfunction rewritten intoThe function reflashPosition () {
TempPosition. X +=vx * Time. DeltaTime;
Vx=ag + a * Time. DeltaTime;
TempPosition. + y=vy * Time. DeltaTime;
Vy vy +=b * Time. DeltaTime;
}
Or simply use your summary equation s where v0=1/2 a * t * * t + t, but remember the t here is the accumulation of time,
Finally, now that you have to write their own velocity update strategy, then the rigidbody here does not make sense, unless you want to use their own collision detection, can be used if the rigidbody, that you call the physics method but he is good for you
CodePudding user response:
The building LordThe transform. The position. X=tempPosition. X;
The transform. The position. Y=tempPosition. Y;
This is set to the object, the var n: Transform=Instantiate (newobject, Vector3,10,0 (5), the Transform, rotation); You don't instantiate the object set his position, how does it move?