Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
Birb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gadig
Birb
Commits
9b087dfd
Commit
9b087dfd
authored
Mar 02, 2017
by
Jordan B Mckenney
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
50916e2f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
9 deletions
+55
-9
Assets/Scenes/CharacterTest.unity
Assets/Scenes/CharacterTest.unity
+0
-0
Assets/Scripts/Enemy/BaseEnemy.cs.meta
Assets/Scripts/Enemy/BaseEnemy.cs.meta
+12
-0
Assets/Scripts/Enemy/HorizontalEnemy.cs.meta
Assets/Scripts/Enemy/HorizontalEnemy.cs.meta
+12
-0
Assets/Scripts/Enemy/VerticalEnemy.cs.meta
Assets/Scripts/Enemy/VerticalEnemy.cs.meta
+12
-0
Assets/Scripts/Player/Walk.cs
Assets/Scripts/Player/Walk.cs
+19
-9
No files found.
Assets/Scenes/CharacterTest.unity
View file @
9b087dfd
No preview for this file type
Assets/Scripts/Enemy/BaseEnemy.cs.meta
0 → 100644
View file @
9b087dfd
fileFormatVersion: 2
guid: 2fa9369d1e9167a4597f284fdd394333
timeCreated: 1488500783
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/Enemy/HorizontalEnemy.cs.meta
0 → 100644
View file @
9b087dfd
fileFormatVersion: 2
guid: b7c614524ded8d449a0e9a69feb4809c
timeCreated: 1488500783
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/Enemy/VerticalEnemy.cs.meta
0 → 100644
View file @
9b087dfd
fileFormatVersion: 2
guid: 8cc875501d3e3194eb13415523af8b1f
timeCreated: 1488500783
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/Player/Walk.cs
View file @
9b087dfd
...
...
@@ -11,6 +11,7 @@ public class Walk : AbstractBehavior {
private
float
xScale
;
public
float
realSpeed
;
public
bool
wallSliding
=
false
;
private
int
rightInt
=
0
;
private
int
leftInt
=
0
;
...
...
@@ -31,9 +32,7 @@ public class Walk : AbstractBehavior {
rightInt
=
0
;
leftInt
=
0
;
rightTime
=
inputState
.
GetButtonHoldTime
(
right
);
leftTime
=
inputState
.
GetButtonHoldTime
(
left
);
if
(
inputState
.
GetButtonValue
(
right
))
rightInt
=
1
;
else
...
...
@@ -46,6 +45,7 @@ public class Walk : AbstractBehavior {
if
(
collisionState
.
onGround
)
//movement on ground
{
Debug
.
Log
(
"on ground"
);
realSpeed
=
body
.
velocity
.
x
;
if
(
inputState
.
GetButtonValue
(
right
)
||
inputState
.
GetButtonValue
(
left
))
{
...
...
@@ -62,8 +62,12 @@ public class Walk : AbstractBehavior {
}
}
body
.
velocity
=
new
Vector2
(
realSpeed
,
body
.
velocity
.
y
);
}
else
if
(!
collisionState
.
onWall
)
}
else
if
(!
wallSliding
)
//in air and not sliding
{
if
(
collisionState
.
onWall
&&
(
inputState
.
GetButtonValue
(
right
)
||
inputState
.
GetButtonValue
(
left
)))
wallSliding
=
true
;
Debug
.
Log
(
"not on wall"
);
airSpeed
=
body
.
velocity
.
x
;
if
(
inputState
.
GetButtonValue
(
right
)
||
inputState
.
GetButtonValue
(
left
))
{
...
...
@@ -81,27 +85,32 @@ public class Walk : AbstractBehavior {
}
else
{
if
(
airSpeed
!=
0
)
{
if
(
airSpeed
!=
0
)
{
airSpeed
+=
(-
1
)
*
Mathf
.
Sign
(
airSpeed
)
*
airAcceleration
;
if
(
Mathf
.
Abs
(
airSpeed
)
<
airAcceleration
)
airSpeed
=
0
;
}
}
body
.
velocity
=
new
Vector2
(
airSpeed
,
body
.
velocity
.
y
);
}
else
//handles
on the wall
}
else
//handles
wall sliding
{
rightTime
=
inputState
.
GetButtonHoldTime
(
right
);
leftTime
=
inputState
.
GetButtonHoldTime
(
left
);
Debug
.
Log
(
"on wall"
);
airSpeed
=
body
.
velocity
.
x
;
//only sets a change if the button has been held for a set time
if
(
rightTime
>=
wallClingTime
)
{
airSpeed
=
Mathf
.
Clamp
(
airSpeed
+
airAcceleration
*
(
rightInt
),
-
speed
,
speed
)
;
wallSliding
=
false
;
}
if
(
leftTime
>=
wallClingTime
)
{
airSpeed
=
Mathf
.
Clamp
(
airSpeed
+
airAcceleration
*
(
leftInt
),
-
speed
,
speed
)
;
wallSliding
=
false
;
}
/***
//same as if not on wall and not pressing the buttons
if (!inputState.GetButtonValue(right) && !inputState.GetButtonValue(left))
{
...
...
@@ -113,6 +122,7 @@ public class Walk : AbstractBehavior {
}
}
body.velocity = new Vector2(airSpeed, body.velocity.y);
***/
}
//change localScale depending on direction
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment