#๐Ÿ’ปโ”ƒcode-beginner

1 messages ยท Page 527 of 1

rich adder
#

it depends how you set up your moves

buoyant finch
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[CreateAssetMenu(fileName = "Move", menuName = "Pokemon/Create a new move")]
public class MoveBase : ScriptableObject
{
    [SerializeField] string name;

    [TextArea]
    [SerializeField] string description;

    [SerializeField] PokemonType type;
    [SerializeField] int power;
    [SerializeField] int accuracy;
    [SerializeField] int pp;

    public string Name {
        get { return name; }
    }

    public string Description {
        get { return description; }
    }

    public PokemonType Type {
        get { return type; }
    }

    public int Power {
        get { return power; }
    }

    public int Accuracy {
        get { return accuracy; }
    }

    public int PP {
        get { return pp; }
    }
}

I have this to set up the moves

rich adder
buoyant finch
rich adder
#

in general, because you could store animations anywhere

#

make another SO or mapping class

buoyant finch
#

the code is a little big

#

!code

eternal falconBOT
buoyant finch
#

I use this base to call it

frail hawk
#

did you google "animations on scriptable objects". it will give you some results

rich adder
#

nahh don't mix them

#

seperation of concerns

#

make another SO for example that maps everything

#

someothing like this cs [CreateAssetMenu(fileName = "MoveAnimationMapping", menuName = "Pokemon/Create Move Animation Mapping")] public class MoveAnimationMapping : ScriptableObject { [System.Serializable] public class MoveAnimationPair { public MoveBase move; public AnimationClip animation; }

 [SerializeField] private List<MoveAnimationPair> moveAnimationPairs;

    private Dictionary<MoveBase, AnimationClip> moveToAnimationMap;
buoyant finch
buoyant finch
rich adder
buoyant finch
#

I have a battleunit for controlling all the animations tho

#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;

public class BattleUnit : MonoBehaviour
{
    [SerializeField] PokemonBase _base;
    [SerializeField] int level;
    [SerializeField] bool isPlayerUnit;

    public Pokemon Pokemon { get; set; }

    Image image;
    Vector3 originalPos;
    private void Awake()
    {
        image = GetComponent<Image>();
        originalPos = image.transform.localPosition;
    }

    public void Setup()
    {
        // Instantiate a new Pokemon and assign it to the Pokemon property
        Pokemon = new Pokemon(_base, level);

        if (isPlayerUnit)
            image.sprite = Pokemon.Base.BackSprite;
        else
            image.sprite = Pokemon.Base.FrontSprite;

        PlayEnterAnimation();
    }

    public void PlayEnterAnimation()
    {
        if (isPlayerUnit)
            image.transform.localPosition = new Vector3(-117f, originalPos.y);
        else
            image.transform.localPosition = new Vector3(117f, originalPos.y);

        image.transform.DOLocalMoveX(originalPos.x, 1f);
    }

    public void PlayFaintAnimation()
    {
        var sequence = DOTween.Sequence();
        sequence.Append(image.transform.DOLocalMoveY(originalPos.y -48f, 0.5f));
        sequence.Join(image.DOFade(0f, 0.5f));
    }
}
rich adder
#

hows that relevant to what I sent ?

buoyant finch
#

no it isn't but I am showing what I have done so you can get a better idea

rich adder
#

more or less I get what you're going for, hence the suggested code I sent

buoyant finch
#
public void PlayMoveAnimation(AnimationClip moveAnimation)
    {
        if (animator && moveAnimation)
        {
            animator.Play(moveAnimation.name); // Play the provided animation
        }

I had added this

rich adder
#

the whole thing I sent associates clips with moves

#

to use its easy

[SerializeField] private MoveAnimationMapping animationMapping;
    [SerializeField] private Animator animator;

    public void ExecuteMove(MoveBase move)
    {
        AnimationClip animation = animationMapping.GetAnimationForMove(move);
        if (animation != null)
        {
            animator.Play(animation.name);
        }
        else
        {
            Debug.LogWarning($"No animation found for move: {move.Name}");
        }
    }```
buoyant finch
#

ok let me try it out

rich adder
#

actually you probably want to pass the clip itself not the name, but you get the point

languid spire
#

Animator.Play plays a Animator state not an Animation clip

rich adder
#

ye i messed up there lol

#

but gets the point across hopefully

languid spire
#

not really because op made exactly the same mistake

animator.Play(moveAnimation.name); // Play the provided animation
rich adder
#

wait no..

buoyant finch
#

is this supposed to be a new script btw?

rich adder
languid spire
rich adder
#

true true. Forgot which one to play clips without putting the states

languid spire
#

legacy Animation iirc

rich adder
#

oh okay.. i guess you need to add them in animator first

#

so yeah the clip name can be the animation state name if you drag the clips should be ok

buoyant finch
rich adder
#

mapping

buoyant finch
#

no no I found that the animatorclip is turned into a string

rich adder
#

the animator uses strings as states yes, but the name has to match

#

if animation is called attack_01
then your Animator State has an attack_01 if you dragged that clip in animator window

buoyant finch
#

public class MoveAnimationMapping : MonoBehaviour
{
// Example dictionary to map MoveBase to state names
private Dictionary<MoveBase, string> moveToStateNameMap = new Dictionary<MoveBase, string>();

public string GetAnimationStateNameForMove(MoveBase move)
{
    return moveToStateNameMap.TryGetValue(move, out string stateName) ? stateName : null;
}

}

rich adder
#

no idea why you changed it

buoyant finch
#

is this true?

rich adder
#

you clearly dont understand its purpose

#

the whole point is to grab a specific state/clip

#

why did you use string?

buoyant finch
#

to return the name of the animation state (a string) instead of the animation clip.

rich adder
#

meh if you have clips instead of typing all names it would be easier to put the clip

#

and more modular, you just have to make sure the AnimaClip NAME matches the Animator State its in

buoyant finch
rich adder
buoyant finch
rich adder
buoyant finch
rich adder
#

they have to match. If you animation.name is called attack_01 then in the animator , make sure the gray box also says attack_01

olive lintel
#

hey guys, I think this might be my dumbest question yet, but I'm having trouble while using the law of cosines in order to find the length of a triangle side (passMaxDist).

in my example, I'm solving for A (passMaxDist), and I'm plugging in localAngle for Y, localDist for B, and longDist for C.

It makes zero sense to me why I'm getting NaN for these values, I'm using Mathf.Rad2Deg! :/ even when I try plugging in 0.05f for B, 135 for Y and 1.4 for C, it just shits the bed and gives me NaN. Any help would be greatly appreciated.

languid spire
buoyant finch
rich adder
teal viper
#

If you read my message again, you'll see that I recommend using a render texture, not the other option.

buoyant finch
# rich adder what?

the animation is happening but I need it to occur only when the move is selected in the move selector

rich adder
rich adder
buoyant finch
#

ok wait a moment

buoyant finch
rich adder
buoyant finch
#

without the paired moves only the animator component

rich adder
buoyant finch
#

there is no difference

rich adder
#

and how am i suppoed to know you setup the animator and the moves/pairs correctly ?

#

you just showed a video, and not like you know..the setup?

buoyant finch
#

ok lemme show you

rich adder
#

make a thread while you're at it so its not flooded channel

steep oyster
#

how do I get the transform of the current active camera

ivory bobcat
steep oyster
#

Camera.current.transform?

#

didnt work

astral citrus
#

Hello! I'm new here, could you help me wiht Time.timeScale? I heared that it's bar practice to change it from several peaople, but I didn't find any good points other than "you may want not all objects to be affected" about it. I wan't to do slowdown in my game, and after some research I believe it's ok to change it. Do you have some links to articles may be about it or just suggestions/advice?

ivory bobcat
rich adder
steep oyster
#

object reference not set to instance of object

ivory bobcat
steep oyster
#

i am new to this so I dont know a lot but I have 2 cameras and i am making a parallax background that moves based on camera position, but it stops working when i switch cameras

rich adder
#

just make a Camera reference directly in the inspector and plug them in

#

dont bother with those static props from Camera component

ivory bobcat
#

What stops working? Camera movement, parallax, crash etc?

steep oyster
#

btw, the parallax background is child of main camera

magic panther
#

I'm trying to get the player to read a float from an xml file. This system works, but only for non-float falues, as of right now. What can I do to get this working, without changing the xml file?

Player class --> https://hastebin.com/share/wafonifule.csharp
Defaults (DefaultJrlGameObject class) --> https://hastebin.com/share/amomadeniz.csharp

MovementVariants.xml

<MovementVariants>
    <HorizontalMoveAccel>0.2</HorizontalMoveAccel>
    <WalkSpeed>5</WalkSpeed>
</MovementVariants>

Error: FormatException: Input string was not in a correct format.

(repost due to no reaction/response)

steep oyster
#

but main camera only has cinemachinebrain and the other one have cinemachinevirtualcamera

rich adder
#

well if its inactive how you expect it to move?

#

or is another script moving it

steep oyster
#

I want to move background based on position of current active camera

crisp lodge
#

hello do you know why my character do that ? its happening when my character don't have rotation restriction

rich adder
magic panther
ivory bobcat
steep oyster
rich adder
ivory bobcat
#

Looks like you're teleporting to an incorrect position

steep oyster
rich adder
#

you already have the cinemachine brain, you don't need Camera.current , what you need that for?

steep oyster
#

idk

#

it work now but I use player velocity instead of camera transform

#

to move background

rich adder
#

then you need it make it follow the main camera not the virtual camera if you switch them

#

Cinemachine brain always tells you which virtual camera is active

steep oyster
#

oo okay

rich adder
#

and cinemachine brain will always follow the virtual camera active

steep oyster
#

ok ty!

true parrot
#

hey guys anyone knows any tutrial on making first couple games? i rageuninstaled unity becouse all the tutrials gave me sintax errors for code and i couldnt figure out how to fix them since im new to unity...

eternal falconBOT
#

:teacher: Unity Learn โ†—

Over 750 hours of free live and on-demand learning content for all levels of experience!

rich adder
#

start with the paths, like Essentials -> Junior Programmer etc.
its a slow steady start but will get you setup

night raptor
true parrot
#

i rage quit since it just made me so mad smashed my pc... fixed it back and reinstaled ๐Ÿ˜„

rich adder
#

don't use random youtube vids, follow the structured courses from Unity Learn

slender nymph
#

and read your errors
as i pointed out in the first channel you posted this in, errors for obsolete code will tell you what to use instead

lapis veldt
#

Hello. I have this task assigment where I need to make an object go up and down. The code works well, but I am uncertain about a thing:
For example, I have maxHeight = 10 and minHeight = -1, and my object starts at y = 4.5. Why does it go 10 units instead of y = 10 and why doesn't go to y = -1 and stops at y =4.5?

true parrot
#

... Im actualy not someone you would think as a programmer... Im a chad... i mean not realy im 2 nice of a guy but my friends said i am one so...

#

๐Ÿ˜„

#

i lack patiance but im sick of having bosses who get on my nerves so i want to get into coding

#

or game dev

naive pawn
#

yeah ok please don't bring this here

slender nymph
#

yeah we don't need this moronic "chad vs incel" energy bullshit here

rich adder
#

cringe

true parrot
#

I had lack of patiance since discord didnt let me login as well...

rich adder
#

if you lack patience then coding isn't for you, find another hobby

naive pawn
true parrot
naive pawn
true parrot
#

so unity is c# code mainly?

slender nymph
rich adder
crisp lodge
naive pawn
lapis veldt
true parrot
#

but best to do c#? visual scripting would limit my learnng would it not?

lapis veldt
#

nvm, I found the answer

naive pawn
#

you can use localPosition instead for the local position

slender nymph
naive pawn
slender nymph
#

unless of course the speed is so high that it stays above that position for longer than 1 frame ๐Ÿ˜‰

lapis veldt
night raptor
#

@lapis veldt You may find Mathf.PingPong useful if you want it to go back and fourth forever

true parrot
#

Oh i used to be decent artist when i was kid.. sorry for asking 2 many qestions maybe but is it recomended to learn to make my asets on photoshop on the side or somthing else would be better?

lapis veldt
#

but yeah, transform.localPosition.y did the job

naive pawn
#

as long as unity can import it, you can use it for unity

rich adder
slender nymph
lapis veldt
true parrot
rich adder
#

the least amount of graphics to deal with is easier, the GUI only adds extra complexity noise to learning code

#

ofc its always fun in unity to see stuff move around with a few lines but if you're absolute beginner its better learning how to even do simple arithmetic in code so basic c#, or learn the built in types first at least

spiral narwhal
#
        public void OnPointerEnter(PointerEventData eventData)
        {
            if (!eventData.pointerEnter.CompareTag("Player")) return;
            Debug.Log("OK");
        }

How do I detect a trigger for a UI element

spiral narwhal
#

This does not work

true parrot
#

My net is sooo bad its going to test my patiance XD

slender nymph
rich adder
#

do you have the EventSystem object/component ?

#

if you want to use the EventSystem on colliders you need a Physics Raycaster on the camera

true parrot
rich adder
#

yes @true parrot

spiral narwhal
#

So basically I have a UI element following the mouse when I click a card in the player's hand. And I want to detect if that UI element (which has the Player tag) is "colliding" with the other element

true parrot
spiral narwhal
#

You can see that there's the black image which wants to check if the low-alpha image is hovering over it

#

I could make a static boolean flag when the card is selected and detect the mouse hover, but I thought it would be nicer if I could detect the tag name of the object

rich adder
#

you can just raycast from the EventSystem too, well it already does but you can retrieve info on what is cursor over

spiral narwhal
#

Can you elaborate?

rich adder
#

EventSystem holds PointerData like what object its over

#

you can use graphics raycaster

spiral narwhal
#

Okay thanks

rich adder
crisp lodge
rich adder
#

stick to 1 channel

crisp lodge
#

sry

#

i delete

rich adder
#

pause the game when it start freaking out and see whats happening in scene view, like the anchors etc

sterile radish
#

hi, im making a top down rpg game similar to that of undertale. what is an efficient/effective way to manage/save/set a lot of bools to check if the player did some sort of action and change character dialogue according to the value of those bools? (i.e, a player chose to insult a character, next time they open the game the character is still bitter about them being insulted)

i thought about making a giant list of flags and checking values from there similar to how undertale did it (https://tomat.dev/undertale/flags) but i do not know how/when i would check these bools. undertale uses a switch statement with thousands of cases meaning it can check the bools there as all the dialogue is hard-coded in that script. for my game, i use a singular script which displays dialogue based on inputted dialogue objects. i can share my script if needed

crisp lodge
#

i use a distant Joint

rich adder
crisp lodge
#

what is spring ?

rich adder
#

spring joint

crisp lodge
#

okay i will try

rich adder
crisp lodge
#

oh

#

your character don't rotate with the line

rich adder
#

nop

#

i probably could though

magic panther
#

I am trying to take a slice of a sprite for further use through code, and so far all the TestBlock objects have no sprite being rendered (None (Sprite)) when I run the project.
I suspected it's something wrong with how I run the function, but after double checking, it seems fine. I believe the issue has to do with how I try to get the asset but I'm not sure.
Please ping on reply.

Screenshot #1 - TestStoneTileTileset.png
Screenshot #2 - Graphics folder (Assets -> Graphics -> ...) and it's contents

DefaultJrlGameObject -> https://hastebin.com/share/ufacologid.csharp
TestBlock -> https://hastebin.com/share/qewepilomu.csharp

crisp lodge
timber tide
#

you can do it I believe

fresh arrow
#

can someone help me with this little problem i got?

timber tide
#

If it's code related, do share

fresh arrow
# timber tide If it's code related, do share

using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEditor;
using UnityEngine;

public class Elevator_script : MonoBehaviour
{
public Transform Player;
public Transform Switch;
public Transform DownPos;
public Transform UpPos;
public bool ElevatorIsGrounded;
public float speed;

void Start()
{
    ElevatorIsGrounded = false;
}

void Update()
{

    StartElevator();

}

void StartElevator()
{
    if (Vector2.Distance(Player.position, Switch.position) < 0.5f && Input.GetKeyDown(KeyCode.E)) 
    {

        if (transform.position.y <= DownPos.position.y)
        {
            ElevatorIsGrounded = true;
        }

        else if (transform.position.y >=  UpPos.position.y)
        {
            ElevatorIsGrounded = false;
        }
    }

    if (ElevatorIsGrounded)
    {
        transform.position = Vector2.MoveTowards(transform.position, UpPos.position, speed * Time.deltaTime);
    }

    else
    {
        transform.position = Vector2.MoveTowards(transform.position, DownPos.position, speed * Time.deltaTime);
    }
}

}

timber tide
#

!code

eternal falconBOT
fresh arrow
#

i wrote this code to check if E is pressed then elevator moves

steep oyster
#

my entire camera system randomly stopped working and I ant find the lens ortho size on virtualcamera cinemachine anymore

#

it replaced by vertical fov

rich adder
#

use links for large code, like entire classes

fresh arrow
#

ok

timber tide
#

And probably clarify on the question

rich adder
fresh arrow
#

here you go

#

this is a code for an elevator if e is pressed at ground level it should go up and if it is pressed at the upper level it should go down

#

but it doesnt work i dont know why

rich adder
timber tide
#

Probably want to be using GetKey as well

#

GetKeyDown is one-time until you release I believe, while GetKey is continuously checking as it's held. But first you should learn how to debug your code in print statements via debug.log

fresh arrow
rich adder
#

KeyUp waits for release KeyDown is called the frame you squish down the button

timber tide
#

Actually, GetKeyDown looks fine here. I was thinking you held it for the elevator to move but it's just a switch.

#

Brains a little wired to the other input system right now

fresh arrow
#

no problem

steep rose
#

if the boolean is not getting triggered to true nor false, then one of the if statements is not getting called,

#

wait

#

isn't MoveTowards vector3 and not a Vector2 ๐Ÿค”

fresh arrow
#

I added logs

#

when the game ran it game going to the down position never goes to up position even when i press e

steep rose
#

sorry I was looking at the wrong one

fresh arrow
#

no worries

steep rose
#

well are the logs under the if statement ElevatorIsGrounded and or the else statement under it called?

fresh arrow
#

it continuously says Moving downwards

#

its skips the first if statement and goes directly towards the if else statement with the boolean

#

it cant detect the e im pressing

timber tide
#

Did you log the input, because you have two conditions to go into your switch there

steep rose
#

and are you actually close enough to the button?

fresh arrow
fresh arrow
rich adder
#

always split these up so they can be logged
Vector2.Distance(Player.position, Switch.position) < 0.5f && Input.GetKey(KeyCode.E

var distance = Vector2.Distance(Player.position, Switch.position);
var eKeyHeld = Input.GetKey(KeyCode.E)
Debug.Log($" distance is : {distance} and keyHeld {eKeyHeld}")

fresh arrow
#

ok

timber tide
#
if (Input.GetKeyDown(KeyCode.E)
{
  Debug.Log("E Pressed")
    if(Vector2.Distance(Player.position, Switch.position) < 0.5f)
    {
      Debug.Log("Distance Check")
      if (transform.position.y <= DownPos.position.y)
      {
          ElevatorIsGrounded = true;
      }
  
      else if (transform.position.y >=  UpPos.position.y)
      {
          ElevatorIsGrounded = false;
      }
    }
}
fresh arrow
#

ill try changing the distance

rich adder
#

can also debug the value so you know what numbers you need

timber tide
#

Also worthwhile to learn how to use VS studio debugger so you can just use breakpoints

rich adder
#

Visual Studio Studio

timber tide
#

lel

fresh arrow
#

YOO I FOUND THE PROBLEM

steep rose
#

when checking Euclidean distance using one of the distance functions it checks the models pivot point when using a transform.position I believe (well it just checks the distance between 2 vectors but the vector it checks is the pivot point)

fresh arrow
#

it was the distance all along

#

thanks everyone really appreciate it

past spindle
#

How does data persistence between sessions work on platforms like Unity Play, where there aren't any files downloaded and the game is played online? Does the save data just go on their server?

rich adder
#

unity has playerprefs but can also use via javascript interop
it would get stored in the usersbrowser not their server

magic panther
#

It's being a roadblock

stuck palm
#

how do you guys store your event system / other unity things you're only allowed one of like audio listener?

lone sable
#

Unsure if this is a good place to ask or not TBH but:
Does anyone use the SteamWorks SteamManager script, and, have the issue where when stopping playmode, Steam says you're still playing the game?

lapis veldt
#

is there anyway that I can make the bean not going into squares?

slender nymph
lone sable
slender nymph
#

How have you confirmed that has anything to do with steamworks? Also in the future ask about the thing you are actually having issues with rather than your assumed cause

lone sable
slender nymph
#

If it is caused by steamworks then ask whatever asset dev made the steamworks integration asset you're using (I'm just going to go ahead and assume that since you are asking about non-code issues in beginner code that you didn't use the steamworks sdk directly and are instead using some wrapper asset for it)

lone sable
slender nymph
#

Yeah so you're using Steamworks.NET, a third party asset that wraps the actual steamworks sdk for use in .net

red igloo
#

hey so I am still a noobie at coding and I decided to make a flappy bird clone. I have added a rigid body to the player. I want it to have the same movement system as flappy bird. I have made a custom function called void OnJump there is 3 dots under On. did I do it wrong?

keen dew
#

Put the mouse cursor on top of it and see what it says

lapis veldt
red igloo
sterile radish
#

hi, im making a top down rpg game similar to that of undertale. what is an efficient/effective way to manage/save/set a lot of bools to check if the player did some sort of action and change character dialogue according to the value of those bools? (i.e, a player chose to insult a character, next time they open the game the character is still bitter about them being insulted)

i thought about making a giant list of flags and checking values from there similar to how undertale did it (https://tomat.dev/undertale/flags) but i do not know how/when i would check these bools. undertale uses a switch statement with thousands of cases meaning it can check the bools there as all the dialogue is hard-coded in that script. for my game, i use a singular script which displays dialogue based on inputted dialogue objects. i can share my script if needed (sorry for the repost)

timber tide
rocky canyon
sterile radish
#

okay, here is the script that manages writing dialogue in my game
https://hatebin.com/wzutmkqjqp

and the script that manages displaying it
https://hatebin.com/aadtqsqtlm

if you see a type "DialogueObject" in my scripts just letting you know that it's a scriptable object that holds dialogue, a voice sfx, the dialogue speaker's name, and repsonses

rocky canyon
#

whats ur biggest concern? like what part are you stuck on?

sterile radish
#

im just stuck on how im supposed to implement flags into this system that checks if a bool or smth else is true. and if it is, a new dialogue object replaces the current dialogue object

timber tide
#

I wouldn't really say no to making a class for each type of character assuming you've only a handful of them. Having a base that shares some similarities would be ideal, leaving you with some room to hardcode some logic and events.

#

because doing something completely modular could be a nightmare if you're a beginner in how to organize a lot of this stuff.

#

Dialogue is actually quite a tricky subject and I even use some assets to now deal with it most of the time.

rocky canyon
#

you could have a dictionary of flags and a singleton (game manager type script) that manages those flags..
such as setting a flag true, or setting on back to false..

FlagManager.Instance.SetFlag("InsultedNPC", true); for example

#

you could check the keys and swap dialog when u need.. (im just trying to think of something really simple)

#

ya, i've never made my own dialog system.. as its probably outside my skillset.. theres alot of good assets out there even if I don't use the entire asset it can really help to just peek at the code and see how its done in that specific asset

sterile radish
sterile radish
potent garnet
#

What would be the best way to indicate that all enemies in a given wave are defeated?

#

Iโ€™m instantiating waves by putting enemies under an empty game object and storing them as prefabs inside a serialized field list

red igloo
frail hawk
#

on the rigidbody there are some options

steep rose
frail hawk
#

i would not recommend to change the global gravity

steep rose
#

I'm just displaying the options they could do, of course it would be better to change the gravity directly on the rigidbody if they want nothing else to be effected

rocky canyon
# sterile radish sorry if this is wrong but are you saying that a possible solution could be to m...

my only suggestion was the flagmanager.. if its a singleton or a static class it'd exist thruout the entire game..
and could be accessible anywhere..
for example

    // Set a flag
    flagManager.instance.SetFlag("PlayerFinishedLevel1", true);

    // Get a flag
    bool hasPickedUpRifle = flagManager.instance.GetFlag("PlayerPickedUpRifle");```
as for the rest of the dialog system.. i don't have any useful commentary sorry
rocky canyon
#

tbf, i know alot of people, as well as myself, that thinks Unity's gravity is a bit floating everywhere.. soo I don't see anything wrong w/ cranking up the global gravity just a smidge ๐Ÿค 10-11 makes everything feel a bit more grounded imo

slender nymph
rocky canyon
#

๐Ÿ’ฏ no lies told..

steep rose
#

also they need the rigidbodies gravity disabled if you implement artificial gravity unless they want it doubled

rocky canyon
#

i lied.. i changed it to 10-11 i was over-estimating when looking at my own projects they usually hang out around -10 for gravity

#

simply a fallMultiplier

#

also, that supermario character feeling where u press the button quickly for a small jump and hold it for a long jump seems to make every platformer ive worked on feel much much better..

cosmic dagger
#

I agree. Having a fall multiplier, separate jump multiplier for press and hold, coyote time, and jump threshold (when landing to jump again) definitely makes the player feel more responsive . . .

#

I think there were some other mechanics I did as well, but I can't recall atm . . .

rocky canyon
#

๐Ÿ’ฏ believe all 3 are some of the most important aspects of "feel-good" controllers

#

"buffered jump" is what i've seen that last mechanic called a few times and what i've named my own as well

stuck monolith
#

Me because I know how to make a discord bot I will integrate it to tell me how many players are in the game

grand walrus
#

im trying to make my charakter jump but everytime i do the "if" code i get this message

#

this is how my code looks

frosty hound
#

You have a spelling error?

cosmic dagger
frosty hound
#

Among other things but that's the obvious thing that's underlined.

grand walrus
cosmic dagger
#

Did you check to make sure you typed it in correctly?

grand walrus
#

i copied everything from a tutorial viedeo

frosty hound
#

No you didn't

#

You have a spelling error

grand walrus
#

where?

frosty hound
#

The one that's underlined

cosmic dagger
grand walrus
#

ohhhhhh

#

shit

#

ye i see it

#

lol

#

ok could swear i copied that bcs i had that problem for like 15 minutes and i retyped everything like 10 times

#

but maybe im just stupid

#

thx

#

huh now it falls like a rock

#

and the whenever i press space it doesnt do anything

naive pawn
#

did you attach the component

rancid tinsel
#

is this not the right syntax?

slender nymph
#

UnityEditor.DragAndDrop does not inherit from UnityEngine.Object therefore it cannot be used in FindOjbectsOfType

#

what are you even expecting it to find?

naive pawn
#

syntax is right, but it's semantically incorrect

rancid tinsel
#

wait does that mean UnityEditor has its own draganddrop thing?

grand walrus
slender nymph
grand walrus
rancid tinsel
#

wait lmao it highlighting gaslit me

#

mine is called DragDropSound

naive pawn
#

click the checkbox beside the name

obtuse quarry
rancid tinsel
#

but that was the right syntax for arrays, just wrong class* name

obtuse quarry
#

Oh lol

grand walrus
slender nymph
rancid tinsel
#

im assuming if you really wanted to youd use a for loop then and put them into a list manually?

slender nymph
#

there's also the ToList method if you really wanted a list

rancid tinsel
#

i dont think ive seen that method before

grand walrus
#

can someone pls tell me whats wron with this script?

#

i just want him to jump man

naive pawn
#

what happened to what you had before

grand walrus
#

wellll

#

i had to restart my pc

#

and it was gone

naive pawn
#

angularVelocity is how fast something spins, you want linearVelocity to control how fast something moves

grand walrus
#

oh

naive pawn
#

have you added using UnityEngine;

grand walrus
#

no i havent

naive pawn
#

or yknow the code you posted here earlier

grand walrus
grand walrus
#

the code doesnt 100 percent work

#

he just has "velocity"

naive pawn
#

right, that's somethign that changed with unity 6

#

i'd recommend using official tutorials instead of stuff that isn't kept updated !learn

eternal falconBOT
#

:teacher: Unity Learn โ†—

Over 750 hours of free live and on-demand learning content for all levels of experience!

ivory bobcat
grand walrus
queen rune
#

i'm working on my first unity game, which is vr, i have a guy who's helping me but he does most of the coding (so basically everything) but i want to work on it too. i just don't know much. how do I learn to code?

slender nymph
#

there are beginner c# courses pinned in this channel. and the junior programmer pathway on the unity !learn site is a good place to learn how to use the engine's API. i recommend learning c# separately from unity first as you'll have an easier time with learning the unity specific stuff after taht

eternal falconBOT
#

:teacher: Unity Learn โ†—

Over 750 hours of free live and on-demand learning content for all levels of experience!

frosty hound
grand walrus
#

ye bcs it didnt work but now i got

#

i can finally jump

naive pawn
coral lotus
#

How to do camera switch from certain angle

rocky canyon
#
  • Move the camera's position and rotation.
  • Swap/Toggle from one camera to another
    Cinemachine package makes this pretty simple
light merlin
#

does anyone know why my camera zooms into the body no matter where i move the camera? ask for screenshots of scripts if u need
thanks!

slender nymph
#

check your vcam settings

teal viper
light merlin
#

this is the camerahandler script

rich adder
eternal falconBOT
molten dock
#

!code

eternal falconBOT
solemn dock
#

Hi everyone just checking to see if this is the right place to ask some coding questions

queen adder
#

this or the other channels in the scripting section

solemn dock
#

I'm trying to dip my toes into character customization, starting from ground zero here. From what I've gleamed so far from some assets is that a character would have all possible options attached to them but only the ones being used are set active am I on the right path?

eternal needle
solemn dock
eternal needle
acoustic belfry
#

Hi, i tried to make a script for check for the pointer for make my player sprite flip...and well

#

Technically it half-way works, cuz the player sprite flips, depending on where "the pointer" is in relation with it

#

...the issue is that it only reads the "pointer" as the center of the screen, and doesnt detect the mouse

#

what i did wrong?

teal viper
acoustic belfry
#

ok

#
    }

    void FlipSpriteWithMouse()
    {
        if (Camera.main == null)
        {
            Debug.LogError("No se encontrรณ la cรกmara principal. Asegรบrate de que una cรกmara estรฉ etiquetada como 'MainCamera'.");
            return; 
        }

        Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);


        if (mousePosition.x > transform.position.x)
        {
            if (spriteRenderer != null)
                spriteRenderer.flipX = false;
        }
        else if (mousePosition.x < transform.position.x)
        {
            if (spriteRenderer != null)
                spriteRenderer.flipX = true;
        }
    }
}```
#

This is the (sprite flipping fragment of the) code

#

i strongly believe the rest of it is irrelevant

acoustic belfry
#

it completely ignores the mouse

teal viper
acoustic belfry
#

1:i think yes
2: due Unity's heaviness i think it would be hard

#

so i think no

teal viper
#

Well, then it's kinda hard to help you, as it's not entirely clear what the issue is and what is the context of it.

acoustic belfry
#

well, the idea is this, this is a 2D game where the idea was that if the mouse pointer is on the right of the charatcer, the sprite would face right, and viceversa

#

but...it only does that, with the center of the screen

acoustic belfry
cosmic dagger
teal viper
#

The only thing I can think of is that transform doesn't belong to the character and remains positioned somewhere else(close to the center of the screen).

acoustic belfry
acoustic belfry
#

the transform thing is supossed to swap it...i think

cosmic dagger
acoustic belfry
#

how that would look like?

teal viper
#

Other than that we can't really help you without seeing what happens on the screen

acoustic belfry
#

maybe screen shots?

teal viper
acoustic belfry
#

the only way i know is Obs

#

wich is quite heavy

teal viper
teal viper
teal viper
acoustic belfry
#

it will lag like hell ;-;

#

i mean, every time i turn on Obs it lags a bit, and every time i turn on Unity it lags a bit

#

so by logic, they two turned on together would lag a lot

#

but i can give it a try i guess

rare heart
#

Is there any reason this function would be running twice? (It is tied to an enemy script, and when that enemy script detects collision with the player, it runs this LoseALife function)
public void LoseALife()
{

    if (hasShield == false)
    {

        lives--;
        
        GameObject.Find("GameManager").GetComponent<GameManager>().Lives();
        Debug.Log(lives);
    } else if (hasShield == true)
    {
        //lose the shield
        //no longer have a shield
    }

    if (lives == 0)
    {
        gameManager.GameOver();
        Instantiate(explosion, transform.position, Quaternion.identity);
        Destroy(this.gameObject);
    }
wintry quarry
rare heart
# wintry quarry The number of times a function runs would come down to the code that calls it.

This is the code I have that calls it. It should be called if this enemy gameobject collides with the player, but for some reason, it must be calling it twice. Im not sure why

private void OnTriggerEnter2D(Collider2D whatIHit)
{
if (whatIHit.tag == "Player")
{
//I hit the Player!
whatIHit.GetComponent<Player>().LoseALife();
Instantiate(explosion, transform.position, Quaternion.identity);
Destroy(this.gameObject);
} else if (whatIHit.tag == "Weapon")
{
//I am shot!
GameObject.Find("GameManager").GetComponent<GameManager>().EarnScore(5);
Instantiate(explosion, transform.position, Quaternion.identity);
Destroy(whatIHit.gameObject);
Destroy(this.gameObject);
}
}

wintry quarry
#

The content of the function doesn't matter

eternal falconBOT
wintry quarry
#

If either of the objects involved in this interaction have multiple colliders that could be why

rare heart
#

Or is this unlikely?

wintry quarry
rare heart
#

tysm

teal viper
acoustic belfry
#

the idea is like this proyect i made in godot long ago

#

...wich for an strange reason now Obs frozen

teal viper
acoustic belfry
#

;-;

acoustic belfry
#

i mean

#

no matter how many i move around the map, happens the same

teal viper
#

It always faces one point in the scene

#

Which would make sense if transform in your code was some static object at that position.

acoustic belfry
cloud moss
#

This is gonna make me seem really stupid but I just can't figure it out
I have an Image object in my canvas that I'm using to hold multiple different sprites (that is to say, it's setting itself to a different sprite depending on what data it's given).
It's not having any trouble changing sprites, but no matter which settings I toggle, the sprite always stretches to fill the entirety of the Image's Rect Transform space. I've tried preserving aspect ratio, setting it to native size, setting the source sprite's mesh type to Full Rect, and it still keeps stretching. I'm totally unsure how to fix this.

#

There are far too many images for it to be set to for editing them all to fit the same aspect ratio in photoshop to be a feasible option.

acoustic belfry
summer sphinx
acoustic belfry
#

But im trying to conver from there, to Unity

summer sphinx
#

Oh I see, my bad.

acoustic belfry
#

and yes, its supossed to have dashs, double jumps, walljumps, etc

#

but now im struggling with only the sprite flipping ;-;

summer sphinx
#

I've been meaning to try godot but been too focused with Unity trying to get my 3rd year out of the way

acoustic belfry
#

but thanks for ask :3

#

I tried Godot, is easier to use...but it lacks a lot of tutorials and stuff that might be usefull, and also my teacher said it can make errors and glitches when it exports. So thats why i moved to Unity

teal viper
acoustic belfry
#

50/50 ;-;

summer sphinx
#

Godot brought our GOAT brackeys back though lol

acoustic belfry
#

but i mean

acoustic belfry
#

the transform is on the sprite part

#

wich causes it to flip

#

if the mouse is higher, it flips to one side

teal viper
acoustic belfry
#

;-; sorry. The exact way you want me to modify the code

teal viper
acoustic belfry
#

what do you mean?

#

everything's on the player script

teal viper
#

What GameObject is the script assigned to?

acoustic belfry
acoustic belfry
#

actually, the name of the player

teal viper
#

Take a screenshot

acoustic belfry
#

but that's confidential till i finish it, due copyrights and etc

acoustic belfry
teal viper
#

Of the scene

acoustic belfry
#

the green fella

#

just unity frozen

#

holup a sec

teal viper
#

And take a screenshot of your camera component as well

acoustic belfry
acoustic belfry
#

you mean what the camera has?

teal viper
#

You'd need to learn some unity basics if you want to use the engine. gameObjects and components are 2 of the very most basic concepts in unity.

acoustic belfry
#

i know what gameobjects are

#

components are the propeties of them?

teal viper
#

No

acoustic belfry
#

ok

#

its just i suck at names

teal viper
#

Components are components.
!learn

eternal falconBOT
#

:teacher: Unity Learn โ†—

Over 750 hours of free live and on-demand learning content for all levels of experience!

acoustic belfry
#

i was right, i strongly suck at names and descriptions

teal viper
# acoustic belfry

At this point, the transform is probably not the cause. You'll need to debug the issue, as I can't see anything else that could be wrong.

acoustic belfry
#

this is the components

#

wait

teal viper
#

Well, share the camera component.

acoustic belfry
#

i didnt knew if you would need the ones that are hidden

#

i call those propeties ._. sorry

teal viper
#

If you want to use a perspective camera, you'll need to make sure that you use the correct z coordinate in screen space to world space transformation

acoustic belfry
#

what would be the correct z coordenate?

#

i always thought it was on orthographic o-o

teal viper
acoustic belfry
#

oh, right

#

i forgor i Ctrl-Z that

teal viper
acoustic belfry
#

well, so returning to the cursor part

#

how i modify the code?

teal viper
#

Modify for what purpose?

acoustic belfry
acoustic belfry
#

hol on

#

i think i fix it

teal viper
#

Did you set your camera to orthographic?

acoustic belfry
#

yep

teal viper
#

And it still doesn't work?

acoustic belfry
#

nonono, now IT works

#

yey, well

#

thanks :3

native seal
#

what is the suggested way to handle sorting multiple overlay canvases that are all siblings? In my case, they are different UI tabs and I want the one clicked/dragged to be brought to the top. Reordering the transforms does not work since I believe canvases only sort with sort order? however there is already an order when all of them are on sort order 0, so not exactly sure why. Im trying to avoid setting the sort order since it would require each tab to know the sort order of the others

wintry quarry
native seal
wintry quarry
#

Hierarchy order only matters within a canvas

native seal
#

figured

wintry quarry
#

It doesn't control how different canvases interact

native seal
#

what decides the order when all are on sort order 0?

sour cape
#

anyone else having package manager issues? its not connecting

wintry quarry
native seal
#

got it

queen adder
#

is scripting define symbol in player setting automatically apply to assembly definition or i must add them manually to define constraint in the assembly definition asset ?

languid spire
queen adder
#

So scripting defines is only for dll?

languid spire
#

for creating dll's, yes. What do you think an asmdef does?

queen adder
#

No i mean, does scripting defines only apply to script that is not in any assembly definition, or it also apply to script inside assembly definition ?

#

The scripting defines in the player settings

languid spire
#

the scripting define in player setting is applied to the Assembly-CSharp dll creation only

queen adder
#

Ah i see, so i must add the scripting defines again for each assembly definition right ?

languid spire
#

yes, that is what I said

queen adder
#

Okay thanks sorry i got a little confused there lol

tall spade
#

!code

eternal falconBOT
solemn fractal
#

Hey guys... I have been searching and still not convinced best way to approach this situation. I have the player bullet. But it only spawns when he shoots. But I need to get information about the bullet before it is spawned, and also update it everytime it change it stats, but I cant do it as it says null because of course it didnt spawn yet. How would you approach this ?

wintry quarry
solemn fractal
wintry quarry
solemn fractal
#

So the bullet should know its damage not the player I guess no? Why the player would have that information if the damage is not the player damage, but the bullet damage itself?

wintry quarry
#

it is "damage of bullets created by this player"

#

think of it that way

#

The bullet of course should know its damage, but that's something the player will assign to the bullet when the player spawns the bullet

#

it's not an intrinsic part of the bullet prefab

solemn fractal
#

hmm.. what abouit these other variables I have inside the bullet script. that should then follow the same logic you are saying?

wintry quarry
#

If they are actually things that are stats on the player they should be on the player

#

but really

#

you should wrap all this up in a class

#

or a struct

#

and slap a field of that type on both the player and the bullet

#

the player will hold the stats for what bullets it will spawn

#

and then you just copy it over to bullets as they spawn

solemn fractal
#

hmm, I was trying to save the player script to have more information, but it seems like I would ned to do the way u are saying

wintry quarry
#

Imagine:

public class Player {
  public BulletStats bulletStats; // Stats for bullets this player will spawn
}```
#
void SpawnBullet() {
  Bullet b = Instantiate(bulletPrefab);
  b.stats = this.bulletStats;
}```
solemn fractal
#

hmm.. so BulletStats I would create a new script for that appart of the Bullet script?

wintry quarry
#

I don't really understand the question

solemn fractal
#

BulletStats as you named, that is a script correct?

wintry quarry
#

It's a class

#

or a struct

solemn fractal
#

ok

#

Makes sense

#

that is a good fix

#

thank you for your insights on that

queen adder
#

I also checked the documentation that custom symbol apply to the whole project, but i havent test if it also includes script inside assembly definition

digital hawk
#

Hello !! I have one question, is there anyone who has already made a graphical dialog system ? I would like to have some help !!!!

vernal bone
#

hello, i have some questions.

is there a much sense in making PlayerController not a monobehaviour?
Should i try to get rid of MonoBehaviours in places where it can be omitted. Like making a general MB script for player and inside make multiple others that do things? Or it's better to stick to MB for GameObject stuff and leave other for data and such?
What is a best practice for this kind of situations?

#

pseudoexample:

public class PlayerScript : MonoBehaviours{
    PlayerController _controler;
    
    void Awake(){
        _controler = new PlayerController();
    }
}

public class PlayerController{
    public PlayerController(){
        // here be code
    }
}
keen dew
#

It would be unusual if a player controller wouldn't need to use any monobehaviour methods but yes, if you have a class that doesn't need any of that and you don't need to handle it in the editor then it's usually better for it to not be a monobehaviour

slender sinew
vernal bone
slender sinew
#

in my completely personal opinion, if you are working alone, you can pretty much just do whatever works for you, and therefore you are free to try new stuff out

#

some people like zenject and others dont, for example

#

at the end of the day, it's about creating something, and usually the means of doing so dont really matter that much (clearly demonstrated by many indie games)

#

stick with what you know until you can actually explain / analyze an issue with the approach. If that point never comes, then great

vernal bone
slender sinew
#

each studio has their own opinions as well, so the best way to prepare is to actually just be good at programming and have experience with many things

graceful fractal
#

I need a bit of advice for a project I am working on. The project itself isn't difficult, it is mainly an interactable art gallery.

However, the project needs to support multiple languages. There needs to be a drop down where the user can select English, Korean, Japanese, or Chinese, and the entire app needs to swap its text to that.

What is the best way to go about something like this? My current prototype is a bit inefficient, but it has a Scriptable Object for each language, that contains a list of every word and sentence that is present in every item that has text, and when swapping languages, the system cycles through everything that has text, and replaces it.

It works, but I feel like it is extremely inefficient. Would anyone have advice or tips on how to tackle this please?

languid spire
#

Unity does have a Localization package

graceful fractal
#

I was not aware of that. I'll take a look, though for now, can you perhaps please provide me with the API for it?

graceful fractal
#

thank you

queen adder
#
using UnityEngine;
using System.Linq;
using System.Collections;
public class main : MonoBehaviour
{
IEnumerator seconds(){
yield return new WaitForSeconds(10);
}

void Start()
{
for (int i = 0; i < 5; i++)
{           StartCoroutine(seconds());
            Debug.Log("salam");
}
    }
}
#

in running screen string just appers 5 times in console without waiting

boreal cedar
#

StartCoroutine(seconds());

#

the wait doesnt happen on the main thread

#

if you want to wait a second and print something

#

write it like this

#

void Start()
{
StartCoroutine(DoSomething());
}

IEnumerator DoSomething()
{
for (int i = 0; i < 5; i++)
{
yield return new WaitForSeconds(1f);
Debug.Log($"Salam: {i}");
}
}

queen adder
boreal cedar
#

yea then write the entire logic inside the coroutine

queen adder
#

thanks for time

boreal cedar
#

np ๐Ÿ™‚

tardy tendon
#

Hey everyone. so i am making a mobile game, basically there is a circular boundary and there is a ball and a hitpad. At the start of the game the ball randomlys goes in some direction and your objective is to use the hitpad to keep the ball inside the cirlce and not let it hit the circle. Cool.
The thing is, I have made the bal have 0 zero gravity and i use force to propell it in some random direction at the start of the game and but there is a problem, at some angles the speed of the ball can increase weird. So on every 5 hits, i am increasing the speed of the ball by a bit (equal amount every 5 hits). and the max is 10 magnitude of velocity. but at some weird hits sometimes, the speed of the ball can increase drastically and at some hits it even decreases drastically, So for this i added some checks in Update but to no avail.

To give a better idea of how the game works I added a picture. Anyhelp would be really appreciated

real thunder
#

I am failing to see where it should be doing it's main function - increasing the speed of the ball

tardy tendon
real thunder
#

I am personally not directly seeing the problem, but I can suggest you to go away from physics, I assume you are using standart Dynamic rigidbody?

languid spire
tardy tendon
# real thunder I am personally not directly seeing the problem, but I can suggest you to go awa...

yes i am using dynamic rigidbody. I am sorry i might have worded my problem weirdly. So the thing that is happening is, on every 5 hits between "Ball" and "HitPad" i am increasing the speed of the ball by a bit (same amount every 5 hits) till it reaches a max speed after that it doesnt increase. Whats happening is that sometimes, the HitPad and Ball collides in a way (unintentionally/not same everytime) that the balls speed can either go from 4 (velocity magnitude) to 7 or from 7 to 4.

prime hinge
#

hello every on
my canva (gamecanvas ) start not showing any elements any one has face same problem?

real thunder
#

on the other hand I would rather make my own reflection method in OnCollisonEnter2D and use kinematic rigidbody, because not using physics for this kind of game looks like a way to go

tardy tendon
tardy tendon
real thunder
#

transform.translate totally won't work here

#

if you remove 2d materials it would use the default one btw

#

anyway if you have something with a rigidbody you should never mvoe it via transform

tardy tendon
#

i could think of nothing else, so i tried that as well but yea it went how it should have, total fail

real thunder
#

yeah, I would ve get the angle and then just redirect the velocity

tardy tendon
#

could it be the way i am detecting collisions? cause it only happens when i am moving my hitpad fast or something, but then i even tried raycast and same thing still

real thunder
real thunder
tardy tendon
real thunder
#

If the ball is getting too fast that might be because it just hits the pad several times?
But the decrease in speed is kinda odd

tardy tendon
real thunder
#

try to put on everything friction 0 bounciness 1 material

tardy tendon
#

also on Ball i have set the collision detections to be COntinious

real thunder
real thunder
tardy tendon
velvet mango
#

heyo im trying to create a script to check for enemies within a room, not how many just if there are any. at the moment i was trying to use OnTriggerStay and Tags to see if any enemy is within the trigger collider. if anyone has a better idea please suggest as this doesnt seem to work.

molten dock
real thunder
#

that's true but how it could decrease the speed

tardy tendon
tardy tendon
molten dock
tardy tendon
real thunder
molten dock
#

There is definitely a workaround

real thunder
#

but that would break your code

velvet mango
tardy tendon
tardy tendon
molten dock
real thunder
tardy tendon
real thunder
#

and make a cooldown timer

#

cooldown timer or trigger, yeah

tardy tendon
real thunder
#

what exactly did not work

molten dock
velvet mango
#

oh ok

#

its backticks right?

molten dock
#

!code

eternal falconBOT
tardy tendon
real thunder
#

I mean without clamping

velvet mango
#
 public GameObject Door;
    private bool enemiesPresent = true;

    private void OnTriggerStay(Collider other)
    {
        if (gameObject.CompareTag("Enemy"))
        {
            enemiesPresent = true;
            Debug.Log("EnemyPresent");
        }
        else
        {
            enemiesPresent = false;
            Debug.Log("EnemyNotPresent");
        }

        if (enemiesPresent == false)
        {
            // Animation or Effect called Here
            Invoke("KillDoor",3);
        }

    }

    void KillDoor()
    {
        Door.SetActive(false);
    }
tardy tendon
molten dock
#

using one of the code websites makes it a little easier to read but its okay

velvet mango
#

oh sorry

real thunder
real thunder
molten dock
velvet mango
#

the enemies have rigidbodies but the door doesnt, but the door is still dissapearing just not when the enemies are gone

real thunder
tardy tendon
velvet mango
molten dock
real thunder
#

yeah those are not needing rigid bodies

#

but they are tied to physics

#

I mean colliders update their positions only in physics so if something is somewhere in the update loop but not there for physics system they would get detected likely

#

but that's a super edge case

velvet mango
#

should i have this on
private void FixedUpdate , instead of OnTriggerStay?

#

for when to check?

real thunder
real thunder
#

it would work from anywhere, update or fixedupdate, but I won't recommend to use it every frame, I thought you wanted to do a one time check

velvet mango
#

i want to check if any enemies are in the room until theres none, like once the player kills all of the enemies the door opens

real thunder
#

oh, well, in this case yeah I guess you want OnTriggerStay, sorry

#

from performance perspective, I think it's better

molten dock
#

include the other

velvet mango
#

but wont it then detect ALL rigidbodies?

real thunder
velvet mango
#

OH

molten dock
#

i was being lazy ill type it out in full

#

if (other.gameObject.CompareTag("Enemy"))

#

this door collider encompasses the whole room right

velvet mango
#

yes

#

that didnt work

real thunder
#

that still doesn't fix what I said tho

#

so basically

#

I can only think of one solution rn aside of doing that Physics.OverlapBox / Physics2D.OverlapBox

#

if (other.gameObject.CompareTag("Enemy"))
{
enemiesPresent = true;
Debug.Log("EnemyPresent");
}
replace that with
if (other.gameObject.CompareTag("Enemy"))
{
enemyTimer = 1;
Debug.Log("EnemyPresent");
}

#

and in fixedupdate substract from that timer Time.deltaTime

#

and if it's zero you open the door

#

because in your current realization it just cycles through things inside the trigger collider

#

and if one of them is not an Enemy it opens the door

molten dock
#

your script can be simplified to

if (other.gameObject.CompareTag("Enemy"))
{
enemiesPresent = true;
Debug.Log("EnemyPresent");
}
else
{
// Animation or Effect called Here
Invoke("KillDoor",3);
}

real thunder
#

that still won't fix what I said

molten dock
#

yes

real thunder
#

okay

velvet mango
#

so im kinda stupid and just checked the console, it is only detecting the enemies once

molten dock
#

look at the number next to those

#

if there is one

velvet mango
#

never mind its just doing this

molten dock
#

you should listen to what the other guy is saying really

velvet mango
#

ok

molten dock
velvet mango
#

is it basically adding a time buffer every time the enemy is detected?

real thunder
#

yeah, not adding but setting tho

#

I haven't figure out anything better yet

velvet mango
#

oh it sets to 1 until it no longer detects them

real thunder
#

I would rather set bool to false at the beginning of the loop and set it true if any of enemies is detected, but FixedUpdate runs before OnTriggerStay

velvet mango
#

ok quick question if an object is already within a trigger will OnTriggerEnter work?

real thunder
#

and OnTriggerStay is not a loop, it runs each time for each object

real thunder
velvet mango
#

dang

real thunder
#

unless it spawns there

#

if that's what you mean

#

I guess it will get detected

velvet mango
#

its already placed in the scene

#

within the trigger box

real thunder
#

at the scen start it will trigger one Enter I think

#

double checking is always worthwhile tho

velvet mango
#

then what im hoping is that on death it Triggers OnTriggerExit

real thunder
#

so, no

molten dock
#

do the doors close seemingly randomly

velvet mango
#

they can only open

#

at this moment

molten dock
#

open then

velvet mango
#

it doesnt look random

molten dock
#

what causes it

velvet mango
#

it still happens because of the Invoke

molten dock
#

okay

#

a more professional way to do this, would be to note how many enemies are in this room one time when the player enters it

#

using physics.overlapbox and an int

#

and then reduce the int by one per enemy killed

#

once the int is 0, open the doors

#

little room for errors there

velvet mango
#

i just tried doing the exact same thing but with OnTriggerEnter and Exit

#

which didnt work

#

so ill try that now

stuck palm
#

how can I check once a unity scene has finished loading? I'm using a framework which is meant to have a. callback for this but it's firing early. is there a unity event for when the scene is all done loading?

molten dock
#

changed my mind

velvet mango
molten dock
velvet mango
#

but how am i subtracting that number when they die?

molten dock
#

in whatever code you have for them dying

velvet mango
#

i can see how it might cause problems outside of this one time, like if i killed enemies outside this zone in a previous room it might subtract that from the int

molten dock
#

im resetting my sleep schedule so im probably too poop brained to help

velvet mango
#

all good

#

thanks for the help you did give

#

cause im sure im getting closer to solving this

molten dock
#

know that if youre tired the best thing you can do is sleep then come back to it when you wake up

#

always works for me

velvet mango
#

my predicament is i need it done in 6 hours

#

otherwise im kinda screwed

molten dock
#

lol fuck

velvet mango
#

yeah

molten dock
#

yo start your homework earlier man

velvet mango
#

this was on the backlog

#

and isnt the last item

#

other people in a group project not holding up thier weight and stuff

#

and its left to me

molten dock
jaunty bay
#
System.RuntimeType.InvokeMember (System.String name, System.Reflection.BindingFlags bindingFlags, System.Reflection.Binder binder, System.Object target, System.Object[] providedArgs, System.Reflection.ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, System.String[] namedParams) (at <b11ba2a8fbf24f219f7cc98532a11304>:0)

  private void OnEnable()
    {
        shoot = controller.Player.Shoot;
        controller.Player.Shoot.performed += OnShoot;
        shoot.Enable();
    }

    private void OnDisable()
    {
        controller.Player.Shoot.performed -= OnShoot;
        shoot.Disable();
    }

    private void OnShoot(InputAction.CallbackContext context)
    {
        Vector2 spawnPosition = spawnPoint != null ? spawnPoint.position : Vector2.zero;
        Instantiate(boomerang, spawnPosition, Quaternion.identity);
    }```

jello, i cant quite seem to see the problem here, but does anyone know?
jaunty bay
languid spire
#

then there must be an incompatibility between what is looking for the method and the method signature you have defined

jaunty bay
#

the script actually works, but it just gave that error somehow

burnt vapor
velvet mango
#

im not even a programmer im only a designer

#

i just have the need to know some programming

molten dock
#

game designers do commonly know how to code

#

if you screenshare i can help better

velvet mango
#

screw it im desperate

burnt vapor
#

For things like this I'd inform your teacher on how bad your group communicates

#

But I assume that they don't care

spare mountain
velvet mango
#

oh i have, and the teacher has taken notes

molten dock
#

i think game students are half wanting to make games and half thought thought they would be playing games all day

jaunty bay
languid spire
velvet mango
molten dock
#

you should focus on the project lol

velvet mango
#

yeah

forest mirage
#

how to fix this (Can't add script behaviour 'NpcInteractable'. The script needs to derive from MonoBehaviour!)

molten dock
#

dont think theres such a thing as NpcInteractable

wintry quarry
forest mirage
wintry quarry
#

You should start sharing your code and/or screenshots of your Unity Editor and console window.

#

Right now we can't see your project so we can't tell what's wrong

forest mirage
#

its simple codes look

jaunty bay
#

programming is weird ffs

wintry quarry
#

you need to fix all compile errors, like i already said

#

It doesn't matter how simple the code is, it has errors.

wintry quarry
forest mirage
#

it tell me the error is ChatBubble3D it not exits in the current context

wintry quarry
forest mirage
#

ok....................

wintry quarry
#

So, either add the missing using directive

#

Or make sure you're only using things that actually exist

hexed terrace
#

ChatBubble3D is probably an asset? Which will be in its own namespace, so you'll need the correct using ... at the top to be able to access the ChatBubble3D type.

forest mirage
#

i will try

wintry quarry
#

RIght I said that....

add the missing using directive

wintry quarry
#

if that is indeed the problem

forest mirage
buoyant finch
#

hello can someone help me I want to make animations for moves for my pokemon game pls explain how to do it with dotween

wintry quarry
buoyant finch
wintry quarry
#

That's extremely vague

buoyant finch
forest mirage
#

look I have the Bubble 3D and it not work @hexed terrace

#

@wintry quarry

wintry quarry
forest mirage
#

ok but look I have the ChatBubble3D and it give me the same error

wintry quarry
#

Show us

forest mirage
wintry quarry
#

That's not a class or script

#

You cannot reference classes that don't exist in code.

forest mirage
#

what i do

wintry quarry
#

Where are you even getting this ChatBubble3D stuff from?

#

You clearly didn't write it yourself

forest mirage
#

i creat one and it didn't work for this i get one from unity assest store it npc dialouge

wintry quarry
forest mirage
#

yes I am stubbed

forest mirage
wintry quarry
#

As for the specifics of this particular problem, you're not providing enough information for us to help you

lilac frigate
#

Hello I'm new-ish to coding/game design I'd say I'm maybe a moderate beginner or expert beginner. Anyway I'm trying to code my first game ever using Unity and right now I have just movement and camera following. It's going to be a 2d platformer. I'm having a couple of issues one I can jump infinitely in the air instead of just a double jump. Two I have no idea wtf I'm doing. Should I be following tutorials to the tea should I code it on my own do I use some tutorials and do other things on my own. Plus I have no idea how to start coding things on my own like I understand coding but how do I start with a new mechanic. Anyway that's just me. If anyone has idea's or tips I'm open to them.

#

Also let me know what information you need to help like code screenshots, files, etc.

wintry quarry
#

I have no idea how to start coding things on my own like I understand coding but how do I start with a new mechanic
This usually comes from unfamiliarity with the Unity API and the basics of how to do things in general and will go away in time as you become more familiar with it.

ivory bobcat
#
if (jumpCount < 2)
{
    ...
    jumpCount++;
}```
lilac frigate
frail hawk
#

first of all you should learn coding instead letting ai do the work for you

lilac frigate
#

This was not ai it was a tutorial

frail hawk
#

sure

lilac frigate
#

I can literally send you the video for it

frail hawk
#

in future send code as code block please.

lilac frigate
wintry quarry
eternal falconBOT
frail hawk
#

debug.log your isGrounded see if it is working correctly when you are on the ground

#

that might be the reason why you can jump in the air too

lilac frigate
#

How excatly do I Debug.log cause it doesn't let me in the code. has an error

frail hawk
#

Debug.Log(isGrounded)

#

also the isJumping boolean

wintry quarry
jaunty bay
#
    {
        controller = new PlayerController();
        Vector2 mouseCoords = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        Debug.Log(mouseCoords);
    }

    private void OnEnable()
    {
        shoot = controller.Player.Shoot;
        shoot.performed += OnClick;
        shoot.Enable();
    }

    private void OnDisable()
    {
        shoot.performed -= OnClick;
        shoot.Disable();
    }

    public void OnClick(InputAction.CallbackContext context)
    {
        Instantiate(boomerang, mouseCoords, Quaternion.identity);
        Debug.Log(mouseCoords);
    }```

every time Awake() happens, debuglog mouseCoords returns the actual coords. but when debugLog mouseCoords on OnClick happens, it returns 0, 0, and the script does so. does anyone know why?
frail hawk
#

Debug.Log($"{isGrounded} {isJumping}");

wintry quarry
jaunty bay
#

ok2 ty

slender nymph
#

you also need to make sure to update the value of the variable because just assigning it once in Awake will not make it constantly update to the current coordinates

lilac frigate
jaunty bay
wintry quarry
frail hawk
#

yeah it simply means Debug exists inside of both of the namespaces

lilac frigate
#

The debug says they are both false for ever doesn't change

frail hawk
#

well there you have it, make sure to fix these 2 bools

#

the ground detection seems faulty

grand walrus
#

why is my text so low res?

rich adder
grand walrus
#

idek what that means

grand walrus
#

thx

true lava
#

The daynightcycle didnt work :/

#

Im using default unity skybox by the way, the skybox lights are going independently and didnt match with the terrain lights

rough spade
#

how can I make the player able to move sideways while colliding in front? (Like pressing W, colliding, but if you press A or D you can move to the left/right)

    {
        moveDirection = orientation.forward * verticalInput + orientation.right * horizontalInput;

        Vector3 moveForce = moveDirection.normalized * moveSpeed;

        rb.AddForce(new Vector3(moveForce.x, 0, moveForce.z), ForceMode.VelocityChange);
    }```
past spindle
#

I'm trying to do my initial commit, but I get a bunch of errors warning me that the line endings will be changed from 'LF' to 'CRLF' and the commit doesn't go through. Can anybody help with this?

frosty hound
#

As seen by the fact it's trying to commit the Library folder, which you do not want added to your repo.

past spindle
frosty hound
#

You can fix it if you want to get fancy with git, but it's honestly easier just to start a new repo.

#

Make sure you commit it first before adding your project files.

past spindle
#

ok

frosty hound
#

Take the gitignore from the link above as well, and commit it as its own file.

primal jewel
#

@past spindle for the record, looks like your project isnโ€™t in the root of the git repo. Make sure that either the project itself (contents of the folder that has Assets and ProjectSettings folders) is at the root of the repo, or the .gitignore file is placed in the project folder next to Assets and ProjectSettings.

past spindle
#

or does it matter?

primal jewel
#

Either works. If the repo just contains a Unity project, Iโ€™d personally move the project

past spindle
#

I wasn't sure if it would mess with the path the hub needs to open the project

primal jewel
#

The key is the gitignore needs to be next to the project files
And yeah, youโ€™d need to add the new project location to Unity Hub. Takes 5 seconds, though

errant pilot
errant pilot
queen adder
#

what is the proper way to get a world position, and translate it to a canvas postion, when the canvas is using Screen Space - Camera mode?

i was using transform.position = Camera.main.WorldToScreenPoint(worldPosition.position); however, after moving over to not overlay, it causes it to be super off.

queen adder
verbal dome
#

Yeah

#

Give it the parent recttransform as first argument

queen adder
#

hmm, yeah still not working. ends up giving me a value thats 67000, -23000, -67000.

#

exact code is.

void FixedUpdate() {
        if (worldPosition) {
            lastKnownPos = worldPosition.position;
        }

        Vector3 screenPoint = Camera.main.WorldToScreenPoint(lastKnownPos);
        RectTransformUtility.ScreenPointToLocalPointInRectangle(transform.parent.GetComponent<RectTransform>(), screenPoint, Camera.main, out Vector2 localPoint);
        transform.position = localPoint;
        transform.rotation = Quaternion.Euler(0, 0, 0);
    }
#

ah setting it to transform.localposition fixed it, strange, but I suppose.

verbal dome
#

Yeah the method outputs a position relative to the parent rect

#

Not strange, the name Local is in the name

grand walrus
#

why can i not see my text?

polar acorn
#

It's not on a canvas

grand walrus
#

how do i put in on a canvas?

polar acorn
#

Move it onto the canvas

#

And make sure it's a child of one

grand walrus
polar acorn
short hazel
#

In this screenshot you can see the bottom-left corner of the Canvas, it's the two white lines extending up and right off of the screen.
The canvas is huge compared to your world, and it's normal (1px = 1 meter). You can click the Canvas in the Hierarchy, and while having your mouse over the scene view, press F to bring it into view

stuck palm
#

does smoothdamp need time.deltaTime?

#

to stay framerate consistent? or is that done within the function

slender nymph
#

did you look at the docs?

stuck palm
#

can't say i have

hexed dove
#

Hello there, i have an issue with raycasts in 3D... I am making a little game about a cube. There are teleporters in my game, and i have a raycast for the ground check going from my cube to vector3.Down. When i teleport, the raycasts stops detecting any collision.. Could some1 help, i can call if needed because it's really a strange problem...

here is my cube code : https://pastebin.com/xET7auwT
and the tickManager : https://pastebin.com/JSa3QQkJ

thank you for your help

slender nymph
# stuck palm can't say i have

docs should always be the first place you check before asking here. your question would have been answered immediately

slender nymph
# hexed dove Hello there, i have an issue with raycasts in 3D... I am making a little game ab...
  1. if you're going to use pastebin, at least have the courtesy of selecting the language so that there's syntax highlighting so the code is easier to read/navigate
  2. you never invoke your _NextAction delegate which is where you call CheckCollision except for in that CheckCollision method. are you certain that logic for counting the ticks and invoking the delegate shouldn't be inside Update instead? or even DoActionVoid?
#

oh i suppose it's also subscribed to your OnTick event as well. but have you actually done any debugging to find out when/if these methods are actually being called as you expect?

hexed dove
#

yes i've been on this bug for 3 days xD

#

debbuging mode, printing etc

hexed dove
slender nymph
hexed dove
#

yes, how could i detail more.. I will try, i have the blue cubes that are the teleporters. When my cube teleports to the top, like on the second screen, the raycast fires but, nothing happens. He stays blocked. when i tried debbuging, after the teleportation, the raycast doesn't detect the groundTag gameobject. I suppose its because the ray hits the teleporter before it hits the ground. but i have no idea on how to fix it.

here is the cube with the good language : https://pastebin.com/qHSZfVGu

slender nymph
#

you said you've been debugging this for 3 days, what useful information have you found from your debugging efforts? what have you actually done and what did that reveal?

hexed dove
#

the only good info i got was that after teleporting the condition if (_GroundHit.collider.CompareTag(_GroundTag)) at the line 90 in checkcollision doesn't execute. But i think its not relevent after thinking about it because i just use the setmodewait so we dont care about the checkCollision because i invoke the action int the setmodewait

#

i am new to c# so i am missing something for sure but i dont get what

#

is this specific enough ?

slender nymph
#

so you've spent 3 days debugging and the only conclusion you've come to is that the code is not executing?
also this statement "i just use the setmodewait so we dont care about the checkCollision because i invoke the action int the setmodewait" is incorrect because SetModeWait does not invoke the action, it is CheckCollision that is invoking the action, in fact SetModeWait is just assigning the lambda expression that calls CheckCollision to the action that is being invoked in CheckCollision. if CheckCollision is not being called at all anymore, then obviously that action will never be invoked. have you confirmed that this code is actually executing

hexed dove
#

it does execute

slender nymph
#

now verify that the raycast code is actually executing

hexed dove
#

it does execute but stops at the if (_GroundHit.collider.CompareTag(_GroundTag))