Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dyingIsMainstream
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gamejam-gpn15
dyingIsMainstream
Commits
5f119b2e
Commit
5f119b2e
authored
Jun 05, 2015
by
Tim Reiter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added Rocket "target lag" so the target can avoid the rocket.
parent
f6b10275
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
4 deletions
+6
-4
rocket.prefab
Assets/Prefabs/rocket.prefab
+0
-0
Rocket.cs
Assets/Scripts/Rocket.cs
+6
-4
No files found.
Assets/Prefabs/rocket.prefab
View file @
5f119b2e
No preview for this file type
Assets/Scripts/Rocket.cs
View file @
5f119b2e
...
...
@@ -6,8 +6,9 @@ public class Rocket : MonoBehaviour
#
region
members
public
int
damagePoints
=
15
;
public
float
speed
=
1
;
public
float
pushForce
=
20
;
//wie stark das target weggeschubst wird beim aufprall.
public
float
flyToTargetSpeed
=
10f
;
public
float
speed
=
1f
;
public
float
pushForce
=
20f
;
//wie stark das target weggeschubst wird beim aufprall.
private
Rigidbody2D
body
;
public
Transform
target
;
...
...
@@ -25,8 +26,9 @@ public class Rocket : MonoBehaviour
//update direction:
Vector3
direction
=
target
.
position
-
transform
.
position
;
body
.
velocity
=
(
float
)
speed
*
direction
.
normalized
;
transform
.
rotation
=
Quaternion
.
Euler
(
0
,
0
,
-
Mathf
.
Rad2Deg
*
Mathf
.
Atan2
(
direction
.
x
,
direction
.
y
));
body
.
velocity
=
Vector2
.
Lerp
(
body
.
velocity
,
(
float
)
speed
*
direction
.
normalized
,
Time
.
deltaTime
*
flyToTargetSpeed
);
Quaternion
newRotation
=
Quaternion
.
Euler
(
0
,
0
,
-
Mathf
.
Rad2Deg
*
Mathf
.
Atan2
(
direction
.
x
,
direction
.
y
));
transform
.
rotation
=
Quaternion
.
Slerp
(
transform
.
rotation
,
newRotation
,
Time
.
deltaTime
*
flyToTargetSpeed
);
}
void
OnTriggerEnter2D
(
Collider2D
other
)
...
...
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