Improve player movement and add collision
This commit is contained in:
@@ -12,6 +12,7 @@ GameObject:
|
||||
- component: {fileID: 7692843314178062085}
|
||||
- component: {fileID: 6118034672792182209}
|
||||
- component: {fileID: 4194995354293255184}
|
||||
- component: {fileID: -4152331571693237436}
|
||||
m_Layer: 0
|
||||
m_Name: Player
|
||||
m_TagString: Untagged
|
||||
@@ -149,6 +150,33 @@ BoxCollider2D:
|
||||
m_AutoTiling: 0
|
||||
m_Size: {x: 12.63, y: 12.63}
|
||||
m_EdgeRadius: 0
|
||||
--- !u!50 &-4152331571693237436
|
||||
Rigidbody2D:
|
||||
serializedVersion: 5
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3739677681433878215}
|
||||
m_BodyType: 0
|
||||
m_Simulated: 1
|
||||
m_UseFullKinematicContacts: 0
|
||||
m_UseAutoMass: 0
|
||||
m_Mass: 1
|
||||
m_LinearDamping: 0
|
||||
m_AngularDamping: 0.05
|
||||
m_GravityScale: 1
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_Interpolate: 0
|
||||
m_SleepingMode: 1
|
||||
m_CollisionDetection: 0
|
||||
m_Constraints: 0
|
||||
--- !u!1 &8669953498445216587
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -6,16 +6,15 @@ public class Teo : MonoBehaviour
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
transform.Translate(
|
||||
Input.GetAxis("Horizontal")*moveSpeed*Time.deltaTime,
|
||||
Input.GetAxis("Vertical")*moveSpeed*Time.deltaTime,
|
||||
0
|
||||
);
|
||||
Rigidbody2D controller = GetComponent<Rigidbody2D>();
|
||||
controller.linearVelocity = new Vector2 (
|
||||
Input.GetAxis("Horizontal"),
|
||||
Input.GetAxis("Vertical")
|
||||
).normalized * moveSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user