Home > other > Unable to acquire role controller ways to change the position object
Unable to acquire role controller ways to change the position object
Time:09-30
Want to do a simple transfer effect, build a simple scenario, two platform, a capsule body (add the character controller components), a small square is responsible for the ACTS as a transfer matrix As is shown in
Transfer matrix of the script is simple, it is whether collision object name is players Public class Teleporter: MonoBehaviour { CharacterController cc.
Private void OnTriggerEnter (starts other) { If (other. GameObject. Name=="Player") { //the Debug Log (" collide ");//collision test whether Cc=other. GetComponent (a); The Debug Log (cc. GameObject. Name);//test whether cc was given the role of the player controller component Cc. The transform. The position=new Vector3 (15, 1, 0); The Debug Log (cc) transform) position. X);//test if cc changed position } } }
Results after the operation found that players will not be changed, and the console to play out the information display cc indeed change the position x axis
CodePudding user response:
Test your code, no problem, you check the mobile location is correct, whether there is square and the controller is the trigger