There are no errors on the Unity editor before the build, but it works fine
When you build it, it's both on the actual machine and on the editor.
I am troubled that only the AddForce function does not work.
By the way, restarting the Unity editor works fine on the editor.
This is an Android 4.4 device.
The Unity version uses the 5.6.3p2 Personal license in Windows 7 and
The functions in question are as follows:
public void Shoter(float Angle, float ShotPower){
floatShotX=Mathf.Cos(Angle)*speed*ShotPower;
floatShotZ=Mathf.Sin(Angle)*speed*ShotPower;
Rigidbody RB = transform.GetComponent<Rigidbody>();
RB.AddForce (new Vector 3 (ShotX, 0.0f, ShotZ), ForceMode.Impulse);
Gctrl.GetComponent<GameController>().DebugText(ShotX.ToString()+":"+ShotZ.ToString(),1);
}
I'm adding a debug text output to the last line.
This seems to be working without any problems, so it seems that only the AddFoce function is not working.
Originally, it worked fine on the actual machine, but
when the Resources.Load function adds the process of loading objects containing this function into the scene.
There was a symptom that did not work on the Unity editor or on the actual machine.
I returned to the original state, but it looks like the one I mentioned earlier.
By the way, once you deactivate the object in GameObject.SetActive(false),
GameObject.SetActive(true) back to active
The AddFoce function will not work. Is this normal operation?
If anyone has experienced similar symptoms or knows how to solve them,
Please let me know.
Resolved.
The problem is different from the previous function
Forcing Rigidbody to sleep when the speed of an object drops below a certain level
I was doing it, but during development, the process that was running after getting the initial speed
When you create a build, instance, or change the active state, the order is organized and reversed.
The reason was that I couldn't get the initial speed.
It was resolved by explicitly specifying the timing of the process.
I'm sorry for the trouble caused by the rudimentary oversight.
© 2024 OneMinuteCode. All rights reserved.