Oshigawa
Full Member
 
Posts: 228
Posts: 228
|
Post by Oshigawa on Apr 22, 2016 10:36:48 GMT
Hi again,
i added KillableListener to enemy game object and a piece of code. Code calls the CameraShake method from the MainCamera game object, the idea is the screen shakes when the enemy gets despawned.
Here's the code:
public virtual void Despawned() {
GameObject MainCamera = GameObject.Find ("MainCamera");
CameraShake cameraShake = MainCamera.GetComponent<CameraShake> ();
cameraShake.enabled = true;
} But i get the error
error CS0246: The type or namespace name `CameraShake' could not be found. Are you missing a using directive or an assembly reference? Any ideas?
|
|
|
Post by DarkTonic Dev on Apr 22, 2016 15:48:47 GMT
Did you write CameraShake? You are probably missing the "using namespace X" for it. Not sure what X is, so go look at the CameraShake class and see what the namespace is.
|
|
Oshigawa
Full Member
 
Posts: 228
Posts: 228
|
Post by Oshigawa on Apr 22, 2016 16:04:36 GMT
Here's the script, no namespace, sorry if it's messy, im on tapatalk.
public class CameraShake : MonoBehaviour {
private float ShakeY = 0.8f;
private float ShakeYSpeed = 0.8f;
public void setShake(float someY)
{
ShakeY = someY;
}
void Update()
{
Vector2 _newPosition = new Vector2(0, ShakeY);
if (ShakeY < 0)
{
ShakeY *= ShakeYSpeed;
}
ShakeY = -ShakeY;
transform.Translate(_newPosition, Space.Self);
}
}
Edit: fixed the script to be in code form.
|
|
|
Post by DarkTonic Dev on Apr 22, 2016 16:22:12 GMT
Ok then what's the folder path for that script? assets/standardassets something?
|
|
Oshigawa
Full Member
 
Posts: 228
Posts: 228
|
Post by Oshigawa on Apr 22, 2016 16:25:21 GMT
It's in root of the assets
|
|
|
Post by DarkTonic Dev on Apr 22, 2016 18:04:17 GMT
Try moving your scripts to assets/standard assets and see if that works.
|
|
Oshigawa
Full Member
 
Posts: 228
Posts: 228
|
Post by Oshigawa on Apr 25, 2016 8:06:14 GMT
All well now, thanks.
|
|
|
Post by DarkTonic Dev on Apr 25, 2016 15:03:42 GMT
Ok cool
|
|
Oshigawa
Full Member
 
Posts: 228
Posts: 228
|
Post by Oshigawa on Apr 28, 2016 9:55:22 GMT
Hi, i've got one more question regarding the issue of killables. I'm calling the event from the killable listener attached to the prefab spawning in a wave, and so when the event (in this event, dispawn) occurs i will trigger the event as much times as the prefabs despawned, or when the whole wave is despawned?
Edit:
I've found a more elegant solution, simply spawn an empty moving object with 2dboxcollider which will trigger the event upon reaching the player. Alas, the object is not spawning, any ideas?
Everything's set up as usual, as a wave with 1 min to spawn, 1 max to spawn, it's in the bosspool.
|
|
|
Post by DarkTonic Dev on Apr 28, 2016 17:28:41 GMT
Check for errors in the Console.
Also check "active mode" which can disable the spawned.
|
|
Oshigawa
Full Member
 
Posts: 228
Posts: 228
|
Post by Oshigawa on May 5, 2016 5:07:06 GMT
For gods sake, i didn't put the rigidbody -_- everything's good
|
|
|
Post by DarkTonic Dev on May 5, 2016 15:41:37 GMT
Hopefully the logs helped you figure that out?
|
|
Oshigawa
Full Member
 
Posts: 228
Posts: 228
|
Post by Oshigawa on May 6, 2016 10:23:24 GMT
Hopefully the logs helped you figure that out? Yes! 
|
|
|
Post by DarkTonic Dev on May 6, 2016 15:24:21 GMT
Awesome!
|
|