Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
F
FireballsClone
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
9731021
FireballsClone
Commits
756045ce
Commit
756045ce
authored
Mar 08, 2021
by
Parsa Rahmaty
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cannon shooting mechanics updated
parent
664f7575
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
12 deletions
+11
-12
SampleScene.unity
Assets/Scenes/SampleScene.unity
+2
-2
CannonControls.cs
Assets/Scripts/CannonControls.cs
+9
-10
No files found.
Assets/Scenes/SampleScene.unity
View file @
756045ce
...
@@ -495,7 +495,7 @@ GameObject:
...
@@ -495,7 +495,7 @@ GameObject:
-
component
:
{
fileID
:
1827272340
}
-
component
:
{
fileID
:
1827272340
}
m_Layer
:
0
m_Layer
:
0
m_Name
:
Cannon
m_Name
:
Cannon
m_TagString
:
Untagged
m_TagString
:
Player
m_Icon
:
{
fileID
:
0
}
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_StaticEditorFlags
:
0
...
@@ -530,7 +530,7 @@ MonoBehaviour:
...
@@ -530,7 +530,7 @@ MonoBehaviour:
m_EditorClassIdentifier
:
m_EditorClassIdentifier
:
projectile
:
{
fileID
:
3972782314967972539
,
guid
:
2237038f8f5183148913886475229ea4
,
projectile
:
{
fileID
:
3972782314967972539
,
guid
:
2237038f8f5183148913886475229ea4
,
type
:
3
}
type
:
3
}
shootingDelay
:
50
shootingDelay
:
0.18
cannonColliders
:
cannonColliders
:
-
{
fileID
:
1389915129
}
-
{
fileID
:
1389915129
}
-
{
fileID
:
1384577412
}
-
{
fileID
:
1384577412
}
Assets/Scripts/CannonControls.cs
View file @
756045ce
...
@@ -5,10 +5,10 @@ using UnityEngine;
...
@@ -5,10 +5,10 @@ using UnityEngine;
public
class
CannonControls
:
MonoBehaviour
public
class
CannonControls
:
MonoBehaviour
{
{
[
SerializeField
]
private
GameObject
projectile
;
[
SerializeField
]
private
GameObject
projectile
;
[
SerializeField
]
private
in
t
shootingDelay
;
[
SerializeField
]
private
floa
t
shootingDelay
;
[
SerializeField
]
private
Collider
[]
cannonColliders
;
[
SerializeField
]
private
Collider
[]
cannonColliders
;
private
in
t
delay
;
private
floa
t
delay
;
private
int
framesLeftToShoot
=
0
;
// the number of frames passed since last shot
private
float
framesLeftToShoot
=
0f
;
// the number of frames passed since last shot
void
Start
()
void
Start
()
{
{
...
@@ -19,8 +19,7 @@ public class CannonControls : MonoBehaviour
...
@@ -19,8 +19,7 @@ public class CannonControls : MonoBehaviour
{
{
if
(
Input
.
GetKey
(
KeyCode
.
Space
))
if
(
Input
.
GetKey
(
KeyCode
.
Space
))
{
{
Debug
.
Log
(
delay
);
if
(
framesLeftToShoot
<=
0f
)
if
(
framesLeftToShoot
==
0
)
{
{
// start shooting cannonballs
// start shooting cannonballs
GameObject
childObject
=
Instantiate
(
projectile
)
as
GameObject
;
GameObject
childObject
=
Instantiate
(
projectile
)
as
GameObject
;
...
@@ -29,19 +28,19 @@ public class CannonControls : MonoBehaviour
...
@@ -29,19 +28,19 @@ public class CannonControls : MonoBehaviour
childObject
.
transform
.
parent
=
gameObject
.
transform
;
childObject
.
transform
.
parent
=
gameObject
.
transform
;
childObject
.
transform
.
localPosition
=
new
Vector3
(
0
,
0
,
0
);
childObject
.
transform
.
localPosition
=
new
Vector3
(
0
,
0
,
0
);
framesLeftToShoot
=
delay
-
1
;
if
(
delay
>
(
shootingDelay
*
1f
)
/
2f
)
if
(
delay
>
(
shootingDelay
*
1
)
/
2
)
delay
*=
0.95f
;
delay
--
;
framesLeftToShoot
=
delay
;
}
}
else
else
{
{
framesLeftToShoot
--
;
framesLeftToShoot
-=
Time
.
deltaTime
;
}
}
}
}
if
(
Input
.
GetKeyUp
(
KeyCode
.
Space
))
if
(
Input
.
GetKeyUp
(
KeyCode
.
Space
))
{
{
delay
=
shootingDelay
;
delay
=
shootingDelay
;
framesLeftToShoot
=
0
;
framesLeftToShoot
=
0
f
;
}
}
}
}
}
}
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