Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gadig
four
Commits
cdc94e37
Commit
cdc94e37
authored
Oct 11, 2016
by
Cody A Burchett
Browse files
-m
parent
d35289a0
Changes
2
Show whitespace changes
Inline
Side-by-side
Assets/scene/cburchetTesting.unity
View file @
cdc94e37
No preview for this file type
Assets/script/FlameCrab.cs
View file @
cdc94e37
...
...
@@ -3,9 +3,15 @@ using System.Collections;
public
class
FlameCrab
:
MonoBehaviour
{
//update once grid is ready
//array of positions to move to once grid is ready
//Vector3 [] positions;
public
float
moveDelay
=
5f
;
public
float
speed
=
5f
;
public
float
health
=
10f
;
public
int
moveDistance
=
5
;
float
nextMove
=
0f
;
Vector3
targetLocation
=
-
Vector3
.
up
;
...
...
@@ -22,7 +28,7 @@ public class FlameCrab : MonoBehaviour {
{
if
(
targetLocation
!=
-
Vector3
.
up
)
{
if
((
transform
.
position
-
targetLocation
).
sqrMagnitude
>
.
1
5f
)
if
((
transform
.
position
-
targetLocation
).
sqrMagnitude
>
.
5f
)
{
Move
();
}
...
...
@@ -35,7 +41,7 @@ public class FlameCrab : MonoBehaviour {
else
{
//find new target location to right or left of enemy
int
spacesToMove
=
Random
.
Range
(-
5
,
6
);
int
spacesToMove
=
Random
.
Range
(-
moveDistance
,
moveDistance
+
1
);
RaycastHit2D
hit
=
Physics2D
.
Raycast
(
transform
.
position
,
transform
.
right
,
spacesToMove
,
1
);
if
(
hit
.
collider
)
{
...
...
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