Posts by diliupg

    Hi @JJokelainen!


    I have a separate Audio Manager that looks after all the Music and sound effects. Here is that class.

    What I need to do is to access the Audio on the scriptable object from any other Game object, Player or enemy etc. and send it to the Audio manager to play. What I haven't been able to do is to access the Array on the Scriptable object. Earlier I had sounds on each object the player sounds on the player, the enemy sounds on the enemy etc. What I am trying to do is to learn while building the game. Your responses are much appreciated. Problem solved! :)

    My Sounds class

    my scriptable object script

    Say after creating the scriptable object I add 2 sound clips. How do I access this from my player script?

    Thanks wildj79 for your answer which made me read the docs well and understand. This is the code now and it works as expected.

    in the code below

    everything works fine. BUT if I use

    Code
    1. rayInfo = Physics2D.Raycast( transform.position, transform.position + end, 1 << LayerMask.NameToLayer ( "Enemy" ) );

    then the collision is not detected. Can Someone please explain why??:/:/

    Why is it that if using OnCollision method I have to use


    Snippet

    Code
    1. private void OnCollisionEnter2D ( Collision2D collision )
    2. {
    3.     Debug.Log ( "Hit " + collision.transform.name );
    4.     IDamageble hit = collision.transform.GetComponent<IDamageble>(); }

    and if using OnTrigger method I have to use the code below?

    Snippet

    Code
    1. private void OnTriggerEnter2D ( Collider2D collision )
    2.  {
    3.      IDamageble hit = collision.GetComponent<IDamageble>();
    4.  }

    :/ Why is it that I can access the component without first accessing the transform in one method and not in the other?

    In the 2D mobile Game the Box collider is on the Parent of the Player which is an empty. The Animator is on the child which is a sprite. I have added a crouching animation to this game where on joystick down the player crouches but the Box collider stays the same size as while standing.


    I want to animate the box collider shrinking with the couching animation. The Box collider is on the parent empty and the animator is on the child sprite.


    I simply can't add an animation to the one on the sprite as there is no reference to the Box collider as that is on the parent.

    When I add an animator to the parent and run the game the code throws errors showing that the all the parameters set up for the animator on the sprite are missing when they are all there. I tried adding the two animators as serialized fields from the inspector but it still shows the same results.

    Can someone help me with this? :):!:

    Thank you very much for the reply. How is it possible to Load scenes alongside one that is never destroyed? Can you please explain that a little bit more? I do not understand the " The player of mine has its own scene, own camera and its own lighting. This scene is never unloaded during gameplay. Scenes are loaded alongside this player scene allowing the player to travel seamlessly between all scenes." bit.

    Most of the code in the Damage() Method is common to ALL the scripts. Would it not be better coding practice and also a more efficient way to move the common code to a method in the Enemy.cs script which is the parent script, and then add what ever extra we need as override code?

    Isn't this what we should be doing in all coding? I am asking cause I would like this confirmed by a code Guru. I am still learning.:)

    My apk built successfully (Dungeon Escape Android) with message "Build completed with a result of succeeded".

    But when I install it on my Oneplus 3 phone running Android 8.0.0 on Oxygen OS version 5.0.8, it opens and displays only a blue screen.

    Please HELP!!!!;(

    I solved the problem by putting

    "com.DungeonEscape" (without the quotes)

    in the Package name field.

    Everything built fine but there are two problems which I will post in a new thread as this problem is now solved.

    As you can see I have filled in the necessary slots but i still get this error..

    Can someone please help me to move forward!!!

    Below is the Enemy.cs

    and below is Skeleton.cs

    This code runs but there is always this error in Unity with a yellow triangle


    Parameter 'InCombat' does not exist.

    UnityEngine.Animator:GetBool(String)

    Enemy:Update() (at Assets/Scripts/Enemy/Enemy.cs:35)


    Can anyone explain what is going on:?: