Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Mr BigSock
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gard Aleksander Furre
Mr BigSock
Commits
ff2699ba
Commit
ff2699ba
authored
2 years ago
by
Gard Aleksander Furre
Browse files
Options
Downloads
Patches
Plain Diff
made movement use moveposition and added a timer for knockback to remove speed
parent
868c3569
No related branches found
Branches containing commit
No related tags found
Loading
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
MrBigsock/Assets/Code/Character.cs
+23
-7
23 additions, 7 deletions
MrBigsock/Assets/Code/Character.cs
MrBigsock/Assets/Code/Core/Abilities/AbilityDodge.cs
+1
-1
1 addition, 1 deletion
MrBigsock/Assets/Code/Core/Abilities/AbilityDodge.cs
with
24 additions
and
8 deletions
MrBigsock/Assets/Code/Character.cs
+
23
−
7
View file @
ff2699ba
...
...
@@ -88,6 +88,9 @@ namespace BigSock {
// The direction the character last moved.
protected
Vector2
moveDir
;
// trigger for in knockback.
protected
bool
inKnockBack
=
false
;
/*
The inventory of the character.
...
...
@@ -178,20 +181,30 @@ namespace BigSock {
MovementDir
=
moveDir
,
};
}
/*
Using a courutine to set trigger in knockback.
*/
IEnumerator
knockBackTimer
()
{
inKnockBack
=
true
;
yield
return
new
WaitForSeconds
(
0.15F
);
rb
.
velocity
=
Vector2
.
zero
;
inKnockBack
=
false
;
}
/*
Add Knockback.
Add Knockback.
(used only for dash ?)
*/
public
void
KnockBack
(
float
force
,
Vector2
difference
)
{
rb
.
AddForce
(
difference
*
force
,
ForceMode2D
.
Impulse
);
StartCoroutine
(
knockBackTimer
());
//rb.MovePosition((Vector2)transform.position + (difference * force * Time.fixedDeltaTime));
}
public
void
KnockBack
(
IAttackStats
attack
)
{
Vector2
difference
=
((
Vector2
)
transform
.
position
-
attack
.
Source
).
normalized
;
//KnockBack(attack.Knockback, difference);
rb
.
AddForce
(
difference
*
attack
.
Knockback
,
ForceMode2D
.
Impulse
);
StartCoroutine
(
knockBackTimer
());
}
/*
...
...
@@ -199,8 +212,11 @@ namespace BigSock {
*/
protected
virtual
bool
TryMove
(
Vector2
direction
)
{
moveDir
=
direction
;
if
(
direction
!=
Vector2
.
zero
)
{
rb
.
AddForce
(
direction
*
(
float
)
MovementSpeed
*
Time
.
fixedDeltaTime
,
ForceMode2D
.
Impulse
);
if
(
direction
!=
Vector2
.
zero
&&
!
inKnockBack
)
{
//Using movePosition to get a "snappy" movement.
//rb.AddForce(direction * (float) MovementSpeed * Time.fixedDeltaTime, ForceMode2D.Impulse);
rb
.
MovePosition
((
Vector2
)
transform
.
position
+
(
direction
*
(
float
)
MovementSpeed
*
Time
.
fixedDeltaTime
));
//rb.velocity = (direction * (float) MovementSpeed);
return
true
;
}
return
false
;
...
...
This diff is collapsed.
Click to expand it.
MrBigsock/Assets/Code/Core/Abilities/AbilityDodge.cs
+
1
−
1
View file @
ff2699ba
...
...
@@ -13,7 +13,7 @@ namespace BigSock {
A basic dodge move that gives a push and a short invincibility.
*/
public
class
AbilityDodge
:
BaseAbility
{
public
static
readonly
float
BASE_FORCE
=
0.5
f
;
public
static
readonly
float
BASE_FORCE
=
1
f
;
public
static
readonly
TimeSpan
IFRAME_DURATION
=
new
TimeSpan
(
0
,
0
,
0
,
0
,
500
);
public
override
ulong
Id
=>
201
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment