RightBLockTransform
How do I use Right B Lock Transform
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
28 | float currentX = Mathf.Clamp(transform.position.x, LeftBlockTransform.position.x + 1, RightBLockTransform.position.x - 1); | 1 |
File name: PaddleScript.cs
Copy
14 void Update()
15 {
16 float input;
17
18 if (Input.touchCount > 0)//touch input
19 {
20 input = Input.touches[0].position.x >= Screen.width / 2 ? 1f : -1f;
21 }
22 else//keyboard input
23 {
24 input = Input.GetAxis("Horizontal");
25 }
26
27 transform.Translate(new Vector2(input * speed * Time.deltaTime, 0));
28 float currentX = Mathf.Clamp(transform.position.x, LeftBlockTransform.position.x + 1, RightBLockTransform.position.x - 1);
29 transform.position = new Vector3(currentX, transform.position.y, transform.position.z);
30 }
RightBLockTransform 144 lượt xem
Gõ tìm kiếm nhanh...