2014-09-30 2 views
-4

enter image description here누군가가이 Unityscript를 C#으로 변환 할 수 있습니까?

이것은 무슨 잘못 그것으로 C#에서 내 코드?

using UnityEngine; 
using System.Collections; 

public class qwe : MonoBehaviour { 

    void Update(){ 
     float xP = Input.GetAxis ("Horizontal")*Time.deltaTime * 20; 
     transform.Translate(Vector3 xe = new Vector3(xP,0,0)); 
     transform.position.x = Mathf.Clamp (transform.position.x, -10, 10); 
    } 
} 
+8

죄송하지만 스택 오버플로가 _CODE의 converter_ 없습니다. –

+0

우리에게 오류를 줄 수 있다면 도움이 될 것입니다 ... – Gelidus

+3

코드 스 니펫의 스크린 샷, 정말?! – Dmitry

답변

1

사용을 transform.position을 할당해야이

using UnityEngine; 
using System.Collections; 

public class qwe : MonoBehaviour { 

    void Update(){ 
     float xP = Input.GetAxis ("Horizontal")*Time.deltaTime * 20; 
     Vector3 xe = new Vector3(xP,0,0); 
     transform.Translate(xe); 
     float x = Mathf.Clamp (transform.position.x, -10, 10); 
     transform.position = new Vector3(x,transform.position.y,transform.position.z); 
    } 
} 
0

당신은 이 시도 "= Vector3의 XE를"필요가 없습니다

float xP = Input.GetAxis ("Horizontal")*Time.deltaTime * 20; 
transform.Translate(new Vector3(xP,0,0)); 
transform.position.x = Mathf.Clamp (transform.position.x, -10, 10); 

UPD를 오 , Cattwood이 맞습니다. x 만 수정할 수 없습니다. 새 Vector3 변수를 만들어야합니다.

0

x 값을 사용한 것처럼 Vector3의 한 값을 변경할 수 없습니다. 새 Vector3를 생성하고

관련 문제