#💻┃code-beginner

1 messages · Page 637 of 1

hidden marten
#

woahhhh. let me try this out!

grand badger
#

basically involves following the patterns from above, and using it for rotation
(pattern being: Get Input on Update/LateUpdate --> Consume it for Physics in FixedUpdate)

keen cargo
#

ohh that might be good for my project too

#
using UnityEngine;

public class PlayerLook : MonoBehaviour
{
    public Transform cameraHolder;
    public float sensitivity = 2f;

    private float xRotation = 0f;

    private void LateUpdate()
    {
        float mouseX = Input.GetAxis("Mouse X") * sensitivity * Time.timeScale;
        float mouseY = Input.GetAxis("Mouse Y") * sensitivity * Time.timeScale;

        // Rotate the player body (horizontal rotation - yaw)
        transform.Rotate(Vector3.up * mouseX);

        // Rotate the camera holder (vertical rotation - pitch)
        xRotation -= mouseY;
        xRotation = Mathf.Clamp(xRotation, -90f, 90f);

        cameraHolder.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
    }
}
#

Mine's like this, have a separate cameraholder object

grand badger
#

yeah but make sure to read the documentation:

Changing the rotation of a Rigidbody using Rigidbody.rotation updates the Transform after the next physics simulation step. This is faster than updating the rotation using Transform.rotation, as Transform.rotation causes all attached Colliders to recalculate their rotation relative to the Rigidbody, whereas Rigidbody.rotation sets the values directly to the physics system.
#

this means that this would also need to change:

Vector3 moveVector = transform.TransformDirection(keyboardInput) * speed;
```with
```cs
Vector3 moveVector = rb.rotation * (keyboardInput * speed);
grand badger
quiet crown
#
 private void Update()
  {
      if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
      {
          this.transform.position += Vector3.left * this.speed * Time.deltaTime;
      }
      if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
      {
          this.transform.position += Vector3.right * this.speed * Time.deltaTime;
      }
      if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow))

      {
          this.transform.position += Vector3.up * this.speed * Time.deltaTime;
      }
      if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow))
      {
          this.transform.position += Vector3.down * this.speed * Time.deltaTime;
      }


  }

This is my movement for my character,
is there anyway i can set this so once a key is pressed it switches to a different sprite / animation?

hidden marten
keen cargo
grand badger
#

there's a potential bug hm

#

you better do: if (!wantsToJump) { wantsToJump = Input.GetKeyDown(KeyCode.Space); }
and consume with: void Jump() { AddForce(); wantsToJump = false; }

hidden marten
#

i dont know how to thank you man. your genuinly a life saver

grand badger
#

also, imo try to write AS FEW LINES OF CODE AS NEEDED first while working on the thing

#

as in, while prototype, your 70 line-long script could be 15 lines

#

then you could spend some additional time to clean it up if you feel it grows

#

np 🙂

keen cargo
grand badger
#

also protip -- don't trust the "trust me" source 😆 try for yourself if you're curious otherwise it's fiine

keen cargo
#

well yea bigsob

hidden marten
grand badger
#

I personally found cinemachine limiting my gameplay 😛 (at least as gameplay camera) -- but for cinematics it's nice to have

keen cargo
#

it's actually super nice, I was able to get quite a simple camera bobbing function with it

without it, it gets super complicated as you'll have to lerp some values etc

grand badger
#

hmmm wrong ling again? there, fixed

#

here the only issue is that camera rotation likely won't be smooth enough, because it's done in FixedUpdate (which updates less frequently)

hidden marten
#

however i do like have things more organized. functions makes things organized ykwim

grand badger
#

idk about that xD

#

your current code is chaos to debug imo

keen cargo
#

the thing about functions is that you only really want them if you know that you're gonna reuse them somewhere

#

(usually)

#

you can do organizing with comments for the most part

grand badger
#

mostly because:

  1. You have one-line functions taking 3 lines
  2. Your functions aren't ordered by time-of-execution
hidden marten
hidden marten
grand badger
#

it's a good mindset to have with splitting logic into functions -- but splitting one line into its separate function isn't really proper

#

especially if it's NOT a function you're going to reuse

#

imo you should practice the habit of AS FEW CODE AS POSSIBLE as a beginner

naive pawn
#

each function should have a specific action

grand badger
#

whether that leads to fewer functions or more is secondary

hidden marten
#

thanks a lot guys! i dont know what i'd do without you all

grand badger
#

mainly because less code is easier to work with. Once you have the system fully ready and tested, you can reorganize it if you feel like it

#

np gl hf

naive pawn
#

honestly though i think Jump being in its own function is fine. it lets you easily find it to apply other logic in the future if needed, like animations or ground checks or cooldowns.

but MyInput, MovePlayer, MoveMouse don't really need to exist unless you get more specific with them

ruby zephyr
#

why does SceneManagement does not show to my script? i even put the name space of using UnityEngine.SceneManagement; but...

rare basin
#

wdym doesnt show to my scrpt

ruby zephyr
#

well the error said

Assets\GamePlay.cs(9,9): error CS0103: The name 'SceneManagement' does not exist in the current context

rare basin
#

show the entire script

ruby zephyr
#

_
_
that way I could not use SceneManagement in a function

#
using UnityEngine.SceneManagement;

public class GamePlay : MonoBehaviour
{
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void LoadScene()
    {
        SceneManagement.LoadSceneAsync("SampleScene");
    }
}
rare basin
#

SceneManagement is not a class

#

it's a namespace

#

SceneManager is a class under SceneManagament namespace

ruby zephyr
#

OHHHHHH I DID NOT NOTICE THAT

echo kite
#
    private void FireWeapon()
    {
        readyToShoot = false;
        bulletsLeft--;

        if (recoilScript != null)
        {
            recoilScript.Recoil();
        }
        Vector3 shootingDirection = CalculateDirectionWithSpread();
        GameObject bullet = Instantiate(bulletPrefab, bulletSpawn.position, Quaternion.identity);
        bullet.transform.forward = shootingDirection;
        bullet.GetComponent<Rigidbody>().AddForce(shootingDirection * bulletVelocity, ForceMode.Impulse);

        StartCoroutine(ResetShooting());
    }
``` @swift elbow
swift elbow
#

what obj did you reference for bulletSpawn ? show your inspector

echo kite
swift elbow
#

ok show me

echo kite
swift elbow
#

a little off topic, but you should be calling your recoil function after the bullet is shot, not before

echo kite
#

!code

eternal falconBOT
echo kite
swift elbow
#

i dont see anything wrong. have you debugged the positions of the bullet when it is spawned vs the position of where it's supposed to spawn?

#

also, is this AI?

#

these comments reek of ChatGPT written code

echo kite
swift elbow
#

so is the other one

echo kite
#

i understand the script too

#

ai just saves time

swift elbow
sour fulcrum
#

unfortunately in this case it doesn't as most people here aren't interested in helping people using ai generated code

swift elbow
#

both of them very obviously are

echo kite
echo kite
rare basin
#

so it's not code issue?

echo kite
rare basin
#

then why are you posting this in code related channel?

polar acorn
#

You seem to be spawning the bullets at the wrong place

echo kite
#

why does that happen

polar acorn
polar acorn
#

What did the logs say

echo kite
polar acorn
echo kite
#

but gun has recoil

echo kite
verbal dome
#

You should also check that the bullet's visuals aren't offset weirdly or anything.

sour fulcrum
echo kite
#

when it hits walls

polar acorn
polar acorn
#

If you want help on the internet it's usually best not to directly lie to basic debugging questions

echo kite
verbal dome
#

But they do match

sour fulcrum
#

in programming nothing is obvious

verbal dome
#

So obviously it wasn't obvious

echo kite
polar acorn
verbal dome
polar acorn
verbal dome
polar acorn
#

You don't even know what logs you're writing

echo kite
#

oh

verbal dome
#

Oh man did even these logs come from chatgpt

echo kite
#

i read it incorrectly

polar acorn
#

I can't help someone who just directly lies when being asked questions and can't read their own code I'm out, have fun

#

I got better things to do with my time than wrench answers out of an unwilling subject

echo kite
high solstice
#

anyone know why Instantiate isnt working ?

wintry quarry
#

Your main issue seems to be that your script is not a MonoBehaviour

swift elbow
#

youre not deriving from monobehaviour?

high solstice
#

im being gas lit by c#

high solstice
#

thats exactly what it was

wintry quarry
#

Since you're not deriving from MonoBehaviour you would need to write Object.Instantiate here

swift elbow
wintry quarry
#

but yeah seems like you meant to derive from MB

high solstice
#

ahahah

#

ye works perfect now

#

thanks gents

polar dust
#

you could have rewritten it properly, no jank ai, in the same amount of time and actually end up with working code

swift elbow
#

they were given correct code but thought there was something wrong with it lmao

rocky canyon
#

gottem!

polar dust
swift elbow
echo kite
#

its just camera moving up in sync with bullet

verbal dome
#

Show your bullet prefab

polar dust
#

thats fair, but this is a key issue with ai code. it writes an entire block of code at once, so if theres a problem inside that, it will be hard to find it
had you written it from scratch, testing it out along the way as you write it, if an issue appears early on, you'd have a better chance of fixing it

verbal dome
#

And positions of its children

echo kite
echo kite
#

i took it from yt tutorial

#

and told it turn it into text

#

then it had bugs and it fixed it without problem

#

im talking about recoil script

#

also i think problem is in void start

terse plume
#

There is no way to put a frame-by-frame (flipbook, spritesheet) animated image in uGui? 🙃 (didn't check toolkit)
I already coded my own, but I am wondering if I just failed at google and there is an "animated image" behaviour or something 🤔

polar dust
#

can you explain what it is thats going wrong exactly? ive tried following earlier messages and im not on the same page here

verbal dome
# echo kite

Still does not show where the actual pivot of the bullet is. I don't see if you re in Pivot or Center gizmo mode

echo kite
polar dust
#

well, is that not what you want?
initialGunPosition = gun.localPosition; // Save gun's initial position
this is caching the position, presumably so it can be restored back to it later on

verbal dome
# echo kite

Show the bullet selected with Gizmos set to Pivot, not Center

echo kite
verbal dome
#

You selected its child

wintry quarry
#

This button will turn it on too

echo kite
polar acorn
# echo kite pivot is in center i think

It's kind of funny how adamant you were about making the tank treads as ludicrously realistic as possible and then when it comes to bullets your prefab is just the entire cartridge like someone who's only seen guns in cartoons

rocky canyon
#

unless u plan on shooting it at slingshot speed he'll never even see that little thing 😄

frosty hound
#

He means you don't know how a bullet works.

polar acorn
# echo kite what do u mean

You seemed so committed to military accuracy, then your model for the bullet is the whole cartridge. Including the bit that's just full of gunpowder that will literally explode in order to make the bullet go

rocky canyon
short hazel
#

30% more bullet per bullet

echo kite
#

im trying to make it look like csgo

polar acorn
echo kite
#

i tried unrealistic way u offered me

#

it didnt look good

#

i will finish that one too its just constraints connected to connectors

winter badge
#

Hey folks!, I am trying to practise using Line renderer and I just have very basic 2 3d spheres in my scene and I want to draw a line between them. But I keep getting "Object reference not set to an instance of an Object" at line " lr.SetPosition(i, points[i].position);".
Can anyone please guide me to achieve my goal.

public class Line_Renderer : MonoBehaviour { LineRenderer lr; Transform[] points; private void Awake() { lr=GetComponent<LineRenderer>(); points=new Transform[2]; } public void setUpLine(Transform[] points) { lr.positionCount = points.Length; this.points=points; } void Update() { for (int i = 0; i < points.Length; i++) { lr.SetPosition(i, points[i].position); } } }

winter badge
visual linden
#

~~I believe points=new Transform[2] initializes a new array, but it won't be populated. You need to set points[0], [1] and [2] with references to transforms. ~~ nvm

rare basin
#

is your lineRenderer assigned?

polar acorn
#

Or rather, the positions array you create from it

rare basin
#

why do you even create a array of point in Start()

polar acorn
#

Since you do have an array, it's just full of nulls

rare basin
#

just use the start and end you've assigned in the inspector

#

what do you need the array for

visual linden
#

It's also worth noting a Transform[2] will contain 3 elements, starting with index 0. So even if you populate [0] and [1], you will have an empty (null) element at index 2

winter badge
winter badge
verbal dome
visual linden
polar acorn
winter badge
visual linden
#

finishyourgame I'm a little bit sleep deprived over here, forgive me

visual linden
rare basin
#

yea like it's tottaly super bad design

#

why are you making a separate field for each transform

#

and then make a array from these transforms in update

#

when you can make a array, exposed to the inspector and just drag&drop the transforms you want

#

imagine you will want 5 points, you'll make point1 point2 point3 ... till 5 and then make array out of it? what if you want 20 points?

polar acorn
winter badge
#

Hope you dont mind, I am complete beginner and Now I have removed the Send_Transform Script and I have assigned the Start and End gameObject from inspector. But I still keep getting "Object reference not set to an instance of an Object"

#

This is my inspector

visual linden
rare basin
#

why are you overcomplicating it so much

#
  • make a public/serialized array with your transforms
  • pass that points to the line renderer
green copper
#

I could be wrong, I don't ever want to dunk on a beginner for no reason, but this does give the impression that "vibe coding" was used to create the framework and the desired function isn't as well-understood as it could be

starting from scratch on this function instead of trying to fix what it currently exists as may be easier

rare basin
#

you don't need the pointsCount field aswell

visual linden
polar acorn
polar acorn
rare basin
#

with all the respect but even chat gpt wouldnt make such stuff

polar acorn
#

None of the hallmark

//Add two numbers together to get the result
int x = 3 + 7;
winter badge
#

Guys Now its working 😅 🫡

green copper
winter badge
#

Finally understood I dont need to initialize array if I am setting it from the Inspector.

tribal fulcrum
#

guys does anyone have a good video for making a ui?

rare basin
#

define making a ui

green copper
#

as it currently exists, you don't have a snowball's chance in hell of understanding this code if you go back and read it again to make a change in a week and a half

tribal fulcrum
#

ok im trying to have a little screen of text saying how to play and then i want it to close when u click a button

visual linden
rare basin
visual linden
green copper
tribal fulcrum
#

yeah i dont think im good enough with the basica

tribal fulcrum
#

back to tutorials for me

rare basin
#

he just want's a UI text, not a sprite

#

just add a canvas, add a text, add a button, you'll get it, it's not black magic

green copper
#

he said he wanted a little screen of text saying how to play, for single popups like that I typically use a sprite object over a canvas, but either would work

rare basin
#

why would you use a sprite for displaying tutorial text

#

what

visual linden
#

Or attach it to the camera

green copper
#

I'd use the sprite for the pane, and a textmesh to display the actual text

And attached to the camera assuming this is a first person camera controller

It's what I was taught in my initial unity class and as I say this I'm realizing that goes in the "my proffessor was unhinged" bucket and not the "this is fine and normal" bucket, oops

#

still trying to adjust, that class was useful in some ways but very wonky in others

rare basin
#

you'd use a Sprite for a background and a UI text to display content of that panel?

rare basin
#

that's a felony loll

green copper
#

For the project we got a .png with a blank pane for the text box and were told to put text in there, it didn't specify how in the reading so he told us to use a sprite renderer

rare basin
#

change your school bro

green copper
#

already on it lol

#

working on my first real portfolio project out of the class

visual linden
#

UI is usually just drawn to the screen in the most basic form. You will rarely need to attach it to a camera in 3d space outside of cases like VR, where you need it in worldspace.

rare basin
#

Image exists for a reason

#

don't use Sprite for UI stuff

#

unless in some rare edge cases

green copper
#

Out of curiosity, what's the difference there?

#

I believe you, definitely, I just don't know the difference off the top of my head

rare basin
#

UI scaling

#

dynamic text changes

#

custom ui layouts

#

performance, draw calls

green copper
rare basin
#

and just convience

#

does this work?

#

KINDA

green copper
#

EAUGH

rare basin
#

is it convinant and nice to use?

#

no

green copper
#

Ugghhhhh okay I have a STORY for you

#

my first job out of college was working frontend web design for a nuclear power plant (yes this is real)

visual linden
rare basin
#

definitely stop using Sprite Renderer for UI stuff

green copper
#

one of the team members was assigned to make a header for the generic web-app template, and instead of making it SCALABLE like a normal human he made like ten different bespoke hard coded headers in different sizes, aspect ration, logo variants, etc, and had them assigned by their index number

rare basin
#

you wont be able to achieve different sizes, aspect ratios, scalable panels etc with Sprites as a UI either

#

unless you make some shananingans in the code

naive pawn
green copper
rare basin
#

it's just like any other object in the world space

#

you can move it, rotate it etc

#

place it in whatever position you want

green copper
#

I've played VR games where if you hold an object between the UI and your face, the UI renders on top of it but still looks farther away to your eyes, the parralax frickery gives me a headache and I'd prefer to avoid it, unsure what specifically causes it or if it's some specific choice

vagrant wolf
#

I'm trying to upload game on web but its giving me error "are you missing and assembly reference"

vagrant wolf
#

idk I started coding 2 days ago lol

#

what is it anyways

#

tried searching but i didn't get any help

polar acorn
#

The first step is actually reading the entire error message

copper wind
main gazelle
#
 private void tween_camera(Vector3 axis) {
        System.Action<ITween<float>> circleRotate = (t) =>
            {
                transform.rotation = Quaternion.identity;
                transform.Rotate(axis, t.CurrentValue);
            };

            float startAngle = transform.transform.rotation.eulerAngles.x;
            float endAngle = startAngle + 90;

            // completion defaults to null if not passed in
            transform.gameObject.Tween("RotateCircle", startAngle, endAngle, 0.35f, TweenScaleFunctions.CubicEaseInOut, circleRotate);
    } 
```Heyo, I have a tween library, but I can't seem to figure out why it doesn't work properly if i remove the```c#
transform.rotation = Quaternion.Identity```I'm trying to rotate on top of the current rotation, but the identity resets the rotation that's why I tried removing it, but it breaks the tween completely
vagrant wolf
#

When I upload the game i will let you try it out

#

but i'm getting erros

green copper
#

The only peice of information you have shared is that you are getting a vague error message, that's not something actionable

vagrant wolf
#

Error building player bc scripts had compiler error?

green copper
#

have you tested or run your game at all?

vagrant wolf
#

my scripts don't have errors tho..

green copper
#

did you build the game, or are you trying to put a unity project file into a website

vagrant wolf
#

Ofc i did

vagrant wolf
green copper
#

You said the error came from the website

#

you need to build a game before you put it on a website

#

it would also help if you mentioned which website

vagrant wolf
#

No I'm not uploading it to a website yet. I'm Currently getting error trying to build the game.

green copper
#

Elaborate on this please, what do you mean?

vagrant wolf
#

I meant error in console while trying to build the game

naive pawn
#

"are you missing and assembly reference"
this isn't the error message, it's just a tip on what to look for.
the error message is before that

green copper
#

it would also help if you mentioned things like

  • is this a project you made from scratch or is it a modified tutorial project
  • what version of unity
naive pawn
#

also for future reference, please don't retype errors or code, copy them over directly

vagrant wolf
#

I had using UnityEngine.Android i think thats why

naive pawn
#

copy and pasting

#

ctrl+c, ctrl+v

queen adder
#

How would one go about making a lap system for a racing game that logs what lap the user is in when they pass through an object

rocky canyon
#

Sequential triggers

queen adder
#

genius

vagrant wolf
naive pawn
#

do you not know how to copy and paste text?

vagrant wolf
polar acorn
#

So try it

naive pawn
#

ok, wdym it isn't working then

polar acorn
#

select the message and copy

#

then paste here

rocky canyon
#

U highlight it from the bottom box the extra details after clicking the error

vagrant wolf
#

let me see if i get any errors then i copy

#

I heard uploading on itch.io is good?

green copper
rocky canyon
# queen adder genius

It's the simplest solution.. the only issue I see with it would be being able to reverse around the track backwards to trigger one

#

That wouldn't give u an advantage so not sure if that's a deal breaker lol

rocky canyon
queen adder
#

thats a tough one

rocky canyon
#

Checkpoints the way to go

#

Even if they hidden from. Player

green copper
# vagrant wolf I heard uploading on itch.io is good?

If you currently do not know how to do things like copy and paste text, I'd say you're getting ahead of yourself. I would reccomend taking some kind of computer fundamentals course to get more familiar with your machine, and start with basic personal projects.

I understand the urge to upload your work and share it, but it's exremely unlikely bordering on impossible that after two days you've created something worth the time of someone to play and give feedback on. Game creation is a complicated process, and reviewing for education is a very different prospect to actual sharing with the hopes of getting feedback as a game creator.

eternal needle
# queen adder thats a tough one

not really, you just have some trigger colliders around that are required to be hit before you add to the lap counter. when you add to the counter, reset whatever method youve chosen to indicate that they were all hit.

green copper
gilded canyon
#

I have an issue where my objects bob up and down and move wierdly without any applied forces on fps lower that 144 . I think this these lines r the problem . Any advice on how to fix. Lines-void Update()
{
transform.rotation= Camera.main.transform.rotation;
}

green copper
#

is this code on all objects? Why? where is this script attached?

gilded canyon
#

yes its attached on all the props. Im making a doom-like so i need all the sprites to be billboarded

gilded canyon
#

it works perfectly fine on 144+ fps but is completely broken on anything below

green copper
queen adder
#

you guys are geniuses thank you

green copper
vagrant wolf
median hatch
#

one right before the lap

#

have an invisible wall right before the lap as well

green copper
median hatch
#

only deactivate wall if player passes first trigger

gilded canyon
green copper
gilded canyon
green copper
#

Consistency is improvement, at least! can I get a screenshot of your object heirarchy?

gilded canyon
#

this is the objects parent

#

this is the child

#

the pickups script manages the rotations

green copper
#

if you turn off the pickups script with the checkbox, does it still jitter?

gilded canyon
#

no it doesnt

gilded canyon
green copper
#

can your camera look up?

#

either way, try only using the horizontal axes in the rotation, instead of the entire transform.rotation

gilded canyon
stone ledge
#

!docs

eternal falconBOT
green copper
#

Well, that's very strange... have you tried lookAt?

stone ledge
#

I just finished a script of mine, anybody care to look over it so I can get rid of some bad practice?

gilded canyon
#

physics is wierd ig

green copper
#

Oh, damn, I forgot that Update() is the default

I always add fixedUpdate by force of habit at this point, I forgot to even ask

cosmic quail
stone ledge
keen sand
#

hey can somebody give me player movement code for a capsule

polar acorn
eternal falconBOT
#

:teacher: Unity Learn ↗

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

copper wind
keen sand
#

ok

stone ledge
hollow dawn
naive pawn
#

(since it's on a transform instead of an rb, you could use Translate.Rotate with the delta instead of applying the delta to the existing rotation; or you could basically have the same code but with localRotation instead of rb.rotation)

hollow dawn
naive pawn
#

sure, lateupdate works

hollow dawn
naive pawn
#

which part exactly?

hollow dawn
naive pawn
#

i kinda already told you what you could do

#

just make sure to clamp the rotation

rare canopy
#

Hi, I am planning on starting my 2nd game. I created my first one about 3 years ago. So lost about all knowledge I had. I also wanted to introduce a friend to it. Do you guys happen to have a really good and all-round "tutorial" about how to start with Unity and everything linked, accounts, preparation of your project, publishing your project etc? Would be really helpful instead of just blindly going into it and having a ton of errors afterwards. Thanks already! 🙂

eternal falconBOT
#

:teacher: Unity Learn ↗

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

#

:teacher: Unity Learn ↗

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

rare canopy
mystic anvil
#

I had a question about object movement. If I am facing one direction and I press W it will move forward but then if I look to the opposite direction and press W the object goes backwards. How do I make the object go towards the direction I am facing?

This is how I have it setup.

naive pawn
#

also, see !code

eternal falconBOT
cosmic dagger
wintry quarry
#

transform.Translate moves in local space by default

#

the question is - which object is actually rotating here? Is it the one this script is attached to?

#

Or a different one?

gilded canyon
wintry quarry
#

if your framerate is lower, that means fewer updates per second

#

that is all

#

it never does anything other than running exactly one time per frame

gilded canyon
wintry quarry
#

no it runs once per frame, period.

mystic anvil
wintry quarry
#

not where the object is looking

#

You need to get a reference to the camera and use the camera's Transform to determine which direction to move

#

You can usually get at the camera with Camera.main

gilded canyon
#

yes but im getting odd results when trying to set a position of one object to a another using heldObj.transform.position = holdPos.transform.position;with uncapped fps or even with vsync it works just fine but as soon as i limit fps with code it seems thats it is always a few frames behind. this gets fixed when i use fixed update instead of update in low fps but then it become broken on high fps.

mystic anvil
wintry quarry
wintry quarry
#

All it does is move your camera

mystic anvil
#

Oh ok

wintry quarry
#

You would still access the camera's Transform the same way

gilded canyon
#

also btw both arent being called at the same time ive just kept them in one script so i dont have to send 2

wintry quarry
#

You would need to explain what components are on the object and also how the object that is doing the holding is moving/rotating

#

I'm assuming there's probably a Rigidbody involved here?

#

If that's the case then moving it directly via its Transform is the main issue here.

gilded canyon
#

the rigid body is set to kinematic when its being held

mystic anvil
#

This worked @wintry quarry

gilded canyon
wintry quarry
#

e.g. rb.MovePosition

cosmic quail
wintry quarry
#

yeah the KeyDown in FixedUpdate is also an issue but that's separate

rich adder
mystic anvil
west sonnet
#

Why do you have to multiply stuff by time.deltatime?

rocky canyon
#

bcuse peoples pc's can drastic wildy.. my update() loop may run at 300 fps when urs runs at 100

#

if ur doing calculations.. those need to be scaled to happen at equal rates

wintry quarry
#

deltaTime is exactly that - how many seconds have passed

#

(since the previous frame)

rocky canyon
#

Δ

polar dust
#

in other words, if you want to increase health by 1, every 1 second, if you were to write health += 1; then 60 frames later (assuming stable 60fps), then you will now have 60 health.
whereas time.deltatime is a very small value, so 1 * time.deltatime produces a value that is small enough that, after 60 frames, you will have gained the correct amount of health

analog drift
#

Anyone have a video on how to make a simple changing HUD. I need to make so there is a display of the current player speed and position (jumping, standing, crouching etc.)?

rich adder
rare basin
#

to whatever value you want

rich adder
#

reference the script with the stats, display it on the ui

analog drift
#

Thank you both

quartz fox
#

Dll Not Found Exception!!
I am learning Macos/iOS plugin development in Unity.
plug-in is inside: Assets/Plugins/TestPlugin.bundle
There are two cases
1: Checking in Vmware Macos (intel CPU)
Everything is working fine; there are no errors
2. Testing in real Mac with (Slicon CPU)
We are getting the Dll not found exception.
We even tested with other older plugins and self-made plugins
But none of them are working on a Mac with a silicon CPU.
Only the plugins that are regularly updated by their developers are working.
We are probably missing some settings while building the plugin in Xcode.
Could you please help solve this issue?
Plugin:
https://github.com/gamedev1991/OS-X-Plugin-For-Unity

GitHub

Contribute to gamedev1991/OS-X-Plugin-For-Unity development by creating an account on GitHub.

fleet venture
#

are these editory only

#

what do i use instead?

rich adder
fleet venture
#

idk

rich adder
#

why UnityEngine.Windows?

fleet venture
#

idk

#

it was the first one that came up

hollow dawn
rich adder
fleet venture
#

oh ok

#

thx

rich adder
#

The UnityEngine.Windows.File class is available only for the Universal Windows Platform. It was recommended during the times in which the System.IO.File class was not available for the Universal Windows Platform. Now, the System.IO.File class is available for the Universal Windows Platform, and Unity recommends not using the UnityEngine.Windows.File class anymore, but the System.IO.File class instead.
https://docs.unity3d.com/ScriptReference/Windows.File.html
interesting..

hollow dawn
fleet venture
#

oh

rare basin
#

just by quickly glancing over it

hollow dawn
rare basin
#

No

hollow dawn
rare basin
#

By following the c# standard naming conventions you can Google it up

hollow dawn
rich adder
# hollow dawn should it be IsOnGround?
    void Update(){
        var grounded = IsGrounded();
        HandleDrag(grounded);
    }
    private bool IsGrounded(){
        return Physics.Raycast(transform.position, Vector3.down, playerHeight * 0.5f + 0.2f, ground);
    }
    void HandleDrag(bool grounded){
        rb.drag = grounded ? groundDrag : 0;
    }```
hollow dawn
#

just read it through and that was very useful I will make sure to stick to it

rich adder
#

alt version edited :p

hollow dawn
#

just to clarify do I do the same things to these aswell?

rich adder
#

I prefer not

hollow dawn
#

alright thanks

green copper
#

This sound file should be a clean loopable tone, but when I imported it, it inserted silence on both sides, any way to fix or fix on reimport?

green copper
#

Figured it out, I needed to convert to a WAV

rugged beacon
#
[Serializable]
public class LootTable 
{
    public List<GameObject> loots;
    public int tableChance = 50;
}


[CreateAssetMenu(fileName = "LootTable", menuName = "Scriptable Objects/Loot/Table")]
public class LootTableSO : ScriptableObject
{
    public List<LootTable> table;
}

everytime i open the project the script object keep saying this cant be loaded
i think this script object has serialize issue? but no idea what to do.

rocky canyon
#

sometimes works.. sometimes not.. but yea stick to wav format.. Unity doesn't process it as hard-core

polar acorn
#

Is it a GameObject, an asset, or what?

rugged beacon
polar acorn
#

Do you have any compile errors?

rugged beacon
#

no, no red

polar acorn
#

Try putting only the ScriptableObject class in the file, and move the other one to a different file

rugged beacon
#

when i create it its fine, when i restart unity it lost

polar acorn
#

And make sure the file name of the script matches the SO's class name

bitter pine
#

alright i got a bit of a weird question, is there a way i can make something look at another thing, but have constraints, so like it cant go over -90f, to 90f on a certain axis. Ive tried to do this myself before but itd either not rotate at all, or just move once then stop

rich adder
bitter pine
#

and is there a way to make this occur in a function

bitter pine
rich adder
#

oh the look part, uhh use LookRotation

#

well you can apply the limits after look at too i think

bitter pine
#

oh wait i got it

#

ill take a look

rugged beacon
polar acorn
bitter pine
rugged beacon
bitter pine
#

i did get told that saying min : -90 and Max: 90 is just gonna return 90 but idk how that works

polar acorn
rich adder
polar acorn
#

And there's really no way to know which number that represents the same angle it's going to give you

rugged beacon
polar acorn
#

Do you have a .meta file for both the ScriptableObject script and the instance of it you created from the context menu? They won't show up in unity, you'll need to check in the file system for them

bitter pine
#

in game atlease

bitter pine
#

in code

rugged beacon
#

still exist

polar acorn
rugged beacon
#

i add a random comment of just //
and reload script, and it back to normal

polar acorn
rugged beacon
#

i use github

#

no onedruive

polar acorn
#

Git wouldn't be affecting things unless you actively run git commands, so that wouldn't be it.

earnest wind
#

uhm how can i make it elastic ? it worked with linear but once i made tElastic it displaces it by 1.5-4 (based on duration which is random??? shouldnt be tho?)

private class Move
    {
        public Vector3 direction;  // The movement offset
        public float elapsedTime;
        public float duration;
        public bool IsComplete => elapsedTime >= duration;

        public Move(Vector3 moveOffset, float time)
        {
            direction = moveOffset;
            elapsedTime = 0f;
            duration = Mathf.Max(0.01f, time);
        }
    }
    private float EaseInElastic(float t)
    {
        float c4 = (2 * Mathf.PI) / 3;
        return t == 0
            ? 0
            : t == 1
            ? 1
            : -Mathf.Pow(2, 10 * t - 10) * Mathf.Sin((t * 10 - 10.75f) * c4);
    }
    private List<Move> activeMove = new List<Move>();

    private void Update()
    {
        if (activeMove.Count > 0)
        {
            Vector3 totalMovement = Vector3.zero;
            List<Move> completedMotions = new List<Move>();

            foreach (var motion in activeMove)
            {
                motion.elapsedTime += Time.deltaTime;
                float t = Mathf.Clamp01(motion.elapsedTime / motion.duration);
                float easedT = EaseInElastic(t);

                totalMovement += motion.direction * easedT;

                if (motion.IsComplete)
                    completedMotions.Add(motion);
            }

            transform.position += totalMovement;

            foreach (var motion in completedMotions)
                activeMove.Remove(motion);
        }
    }

    public void MoveObject(Vector3 offset, float duration)
    {
        activeMove.Add(new Move(offset, duration));
    }
polar acorn
#

Unsure then, that was my last idea. If it's not OneDrive or some weird SVN thing I dunno what would cause it

rugged beacon
#

dang

earnest wind
#

i put debug logs and both t and easedT reach 1 at the end

bitter pine
#

ok i got the looking at working, but whenever i clamp the angles it just dont wanna work

#

ima try clamping from 0 to 90 to see if its me or the code buggin

#

nope, its the code, clamping dont work a tall

rugged beacon
# polar acorn Unsure then, that was my last idea. If it's not OneDrive or some weird SVN thing...

if you free can you help me create one of this script object
i wanted to see if my unity broke then
here the script if you can help me

[Serializable]
public class LootTable 
{
    public List<GameObject> loots;
    public int tableChance = 50;
}


[CreateAssetMenu(fileName = "LootTable", menuName = "Scriptable Objects/Loot/Table")]
public class LootTableSO : ScriptableObject
{
    public List<LootTable> table;
}
polar acorn
#

I'm on a phone, can't run it

rugged beacon
#

ok nw

eternal needle
# rugged beacon dang

have you set up much related to this script? if the file name matches, and you have no compile errors, then it most likely is just a meta file issue. If this object isnt used much, you could delete the meta file and unity will recreate it

#

maybe check your version control to see if the meta file ever changed in a weird way

rugged beacon
#

the old instance lose the script but still manage to hold the data

eternal needle
#

Did you rename the class and file name in your IDE before? that is one possible cause for why the meta file might've messed up

rugged beacon
#

not that i rember

#

renaming in ide itself then i can say i never done it, i always try change file in unity project window

eternal needle
#

hm well its hard to speculate what couldve happened, but the advice i was gonna say if you did the above would be move/rename things inside unity to avoid this stuff. I had a similar issue once before and it was a pain in the ass to find what was wrong because the console gave the most vague error

#

and if the code was used in many places 🤷‍♂️ !

rugged beacon
#

for now idk, if it works it work hapy boy
and thanks for the simple solution

wind brook
#

trying to run this code and it's giving me these errors

eternal needle
eternal falconBOT
eternal needle
#

then afterwards, i would split that line up so you can see it more clearly. the errors are quite clear in what they're telling you, but you have everything in 1 statement so its hard to understand which type is which. Plus also that error about how you're using GetComponent is clear if you look at an example from the docs

wind brook
#

Plus also that error about how you're using GetComponent is clear if you look at an example from the docs
yeah that was a silly one

small onyx
#

Hi guys! Hope everyone is well! I was wondering if there is any online documentation or perhaps a manual about most c# fuctions with the unity system. I am very knew to coding and the way i have been learning languages like java and processing is thru code and then reading it, and having a manual to search and read what what does is of great help!

small onyx
sand mesa
#

good evening

#

im trying to control a boolean property in my shader, and for some reaosn it's gone kaput

slender nymph
sand mesa
#

and for some reason, this does exist

#

... do I just se tthe boolean property's value to 1 and 0 and call it a day?

slender nymph
#

yes. and for future reference, don't trust shitty AI to provide information to you

sand mesa
#

damnitall

#

one small thing; is it possible to use one material in multiple instances?

sand mesa
#

in light of recent development

#

how does one get the shader material to work?

#

cause this is what its supposed to look like

#

and its just gone

acoustic sequoia
#

Hey everyone, quick question.

I’m creating a 2d desktop game and the main functionality is based on a square grid and involves planting crops/farming simulator.

My question is:

is it bad practice to use only UI elements for the entire interactive game? Or should I use sprites and use the world coordinate system?

The entire game can be played only by using mouse clicks and drags. Very minimal.

wintry quarry
acoustic sequoia
#

Ok that’s what I thought. Thank you. 🙏🏼

teal viper
sand mesa
#

ah maan

#

any suggestions?

teal viper
sand mesa
#

except...

#

i do- oh for crying-

vast elk
teal viper
#

_MainTex != _MainText
But I assume you noticed that.

vast elk
#

also older shadergraph need you to set the props to global not sure with the newer unity version

sand mesa
#

... global?

#

where?

vast elk
#

on the properties

stiff mirage
#

Is https://learn.unity.com/pathways a great place to start if my goal is to make 2d games & im new to coding

Unity Learn

Free tutorials, courses, and guided pathways for mastering real-time 3D development skills to make video games, VR, AR, and more.

sand mesa
vast elk
sand mesa
vast elk
#

try uncheck the Exposed

#

and then save the shader

#

dont forget

sand mesa
vast elk
#

working?

sand mesa
#

nope

#

i think exposed = visibility

vast elk
#

not sure, usually i am using ASE

#

let me check my shader code first

#

how about activate the override prop declaration

#

while the exposed is turned off

stiff mirage
sand mesa
#

override prop declaration?

vast elk
#

below the Exposed

sand mesa
#

2022.3.57f1

vast elk
sand mesa
#

theres nothing here for scope

#

oh found it

vast elk
#

are you on URP or BIRP?

sand mesa
#

urp

vast elk
# sand mesa urp

ok turn out name and reference should be correct, doubt that it actually do anything and there's some false positif from unity

sand mesa
#

i found it

#

no worries

viscid dagger
#

I want the camera not to exceed the map created at runtime
I tried using cinemachine confiner3d and the idea is to read the size of the map and increase the size of the cameraconfiner to limit the camera
I searched online but still couldn't find a better way
can someone help me

sand mesa
#

Halright

#

why

#

is this block node not active?

#

@vast elk

vast elk
#

is this unlit or 2d shadergraph?

sand mesa
#

unlit

#

and 2d

vast elk
#

sprite unlit right?

sand mesa
#

uh... built in unlit shader?

vast elk
#

wth i thought you said you use URP

sand mesa
#

i thought i did too?

vast elk
#

use alpha clip, but srpite should be rendered using transparent surface type

sand mesa
#

well this tosses a wrench in the plans

vast elk
#

and it need stencil support as well for spiret and UI shader

vast elk
#

and i think it wont work if you didnt have both

#

graph inspector

sand mesa
#

oh

vast elk
#

just change it to transparent

#

it wont work using opaque for sprite

sand mesa
#

okay yay!

naive pawn
#

@sand mesa for fututre reference, this is a code channel, your issue was not a code issue

sand mesa
#

oh right

#

sorry

dense cargo
glacial forge
#

does unity not have the init keyword? I see some posts that say if you include

namespace System.Runtime.CompilerServices
{
    class IsExternalInit
    {
      
    }
}

people say it should work but {init;} is still erroring for me

teal viper
#

Compiler services?

#

Aah, I see. It's something from C# 9 it seems.

#

I don't think unity supports it yet

#

Besides, the init keyword seems to be related to properties, not classes.

#

If that's not what you mean, then maybe provide some context to your question.

glacial forge
#

no it is, its for properties in a class yes

#

its just more useful for some variables instead of making either 100 different constructors or a construct with a bunch of defaults.

#

im surprised that it isn't implemented yet. Its a fairly old feature

teal viper
glacial forge
#

i see.

#

welp thanks for the info

gaunt basin
#

Is there a way to make my button, after it is clicked & deactivated, return to its original color when i bring it back?

#

It changes color on hover

teal viper
#

At least according to 2018 docs.

gaunt basin
#

on what version?

teal viper
gaunt basin
#

Yeah

#

ill send a video real quick actually

keen cargo
#

hey yall, quick question about design patterns -

my lecturer mentioned that it's worth looking into dependency injection (inversion of control) for Unity, but the more I look into it, i start seeing that it's unnecessary as Unity either already uses some form of DI, or that it's just not needed

asked my project teammate as well and she seems to have the same observations

Is it actually worth it to implement some form of dependency injection for unity?

keen dew
#

Strictly speaking all design patterns are unnecessary because you can always do the same thing with any design pattern or without one. It's just a matter of how structured you want the project to be. It becomes more important the more developers work on the same codebase and when it uses automated testing. Some people like to use DI with Unity, most don't, especially solo devs.

eternal needle
keen cargo
eternal needle
# keen cargo Yeah that's why i was thinking if implementing DI is even something worth consid...

It could even just mean calling a method to provide references to your components. You could definitely try a framework once but a lot of opinions I've seen is that it's not really needed. In game dev, I'm always cautious of advice that's related to "decoupling" because at the end of the day your code is pretty much going to be tightly related and cant function without each other. That's just how games work

keen cargo
#

Alrighty thanks 🙏

final kestrel
#

!code

eternal falconBOT
final kestrel
#

This is my CursorManager class. I basically do hide and show cursor here. In my first playable scene I call hide cursor in Awake. The cursor starts hidden but as soon as I move my mouse. It unhides itself somehow. I thought it would go away in the build but it happents there as well. What should I do? I have to press escape to get my pause menu and then close it back to hide the cursor again.

rich adder
polar acorn
#

You might have multiple copies in the scene, so one hides it and the other shows it. Try putting logs in HideCursor and ShowCursor, disabling collapse in your console if it's enabled, and seeing the order those functions are getting called in

final kestrel
#

I did log. Its all hiding cursor. I have been having this issue ever since I started working on this game. I also searched other classes that may be unhiding my cursor too.

#

It starts hidden until I move my mouse to look around.

#

I even tried calling HideCursor 2 times both in awake and in start.

#

I am considering doing it in update only for once too.

cosmic quail
final kestrel
#

Yes

#

I solved it by calling hide cursor in the update as long as the game is not paused.

final kestrel
#

I dont know what else to do though.

#

People saying its a bug in the internet.

#

May be related with my unity version i think

rich adder
final kestrel
#

In vs code. I searched for HideCursor and ShowCursor

rich adder
#

I did say search for the Cursor class

final kestrel
#

I also did that too

#

Searched if i was calling it thats not under my CursorManager class. Like manually

#

Nothing shows up.

rich adder
#

show

final kestrel
rich adder
#

also would probably narrow it to Cursor.visible = true

final kestrel
#

no. The others are just third party stuff that I'm not using.

cosmic quail
final kestrel
final kestrel
rich adder
# final kestrel

how do you know one of those scripts isn't in the scene on a gameobject somehwere?

#

you have 8 files with this Cursor = true so how do you know for sure

polar acorn
# final kestrel

Put a breakpoint on each of those, then run the game through the debugger

rich adder
#

I bet is whatever charcontroller you are using

final kestrel
#

None of the Cursor.Visible = true lines except the one i call it in CursorManager Class meets the breakpoints

verbal dome
#

Because Cursor.visible = someBoolOrCondition is a thing

#

Also are you using some kind of character controller or camera package?

green copper
#

I plan on having a script, MorseTranslator, that holds some functions for transcribing text into both written transcripts and audible sound for morse code for my game project

The functions will be used in a few places, and my plan is to make a monobehavior script, and just attach it to every other script that ends up needing it

is there a better way I haven't heard of?

final kestrel
#

Camera package is just cinemachine. Not sure if you're asking about that. Character controller is just using legacy inputs. I think I followed a youtube tutorial for it when I first started working on the game.

eternal needle
green copper
eternal needle
# green copper The reason being when I was learning, I learned monobehavior was the default and...

im not sure what logic you're gonna use it for, but it sounds like those "transcribing text" methods could even be static. meaning it isnt associated with an instance of the script, it exists with the Type. This is assuming you dont need it to function differently for different objects also.
you use monobehaviour if you want to attach the script to a game object. it doesnt sound like you need the logic on the actual game objects.

timber tide
#

which is why you learn c# first ;p

green copper
#

the name of the class in the college coursebook was "C# programming" and I feel at least mildly failed by them but I do have an additction to game creation now

rich adder
#

teachers having their license from cereal boxes now?

eternal needle
#

i do find it shocking how often people in here talk about doing a course about unity, and the code provided to them is an abomination

green copper
# eternal needle im not sure what logic you're gonna use it for, but it sounds like those "transc...

I'm going to be giving the player a signifigant amount of information, communication, and dialogue through a telegraph, so my game's scripts for dialogue are going to pass through this and be given to the player as beeps, light flashes, or ink scratches depending on difficulty and accessibility settings so I need functions to take text, and output a string that can be taken by any translation object, so Beeper, FlashBulb, ScratchLine, and EasyModeTextBox

Most likely going to use doubles to store the morse, with 0 for dot, 1 for dash, 2 for space between letters and 3 for space between words

slender nymph
green copper
# rich adder teachers having their license from cereal boxes now?

my PHP teacher used to be an AWACS operator for the Navy, and he once started a sentence "This is a non-comprehensive list" with the intonation implying that a noncomprehensive list was a thing to learn about, and not "This is a non comprehensive list.... of functions that work with this thing"

#

local technical college

rich adder
eternal needle
rich adder
green copper
eternal needle
#

yea dont use a double for that. use a list for each number, like a list of enum

rich adder
brave compass
green copper
#

and then Flash bulb will turn

111131

flash 30ms (x4)
pause 30ms (x1) etc

green copper
rocky canyon
# final kestrel

best to keep ur cursor logic in a single place.. easier to deal with.. if the cursor state changes.. i know exactly who did it

rich adder
#

enum would also be good

eternal needle
#

you have the string anyways. mapping . to flash is the same as mapping 1 to flash

green copper
rich adder
#

not even overkill thing, its also easier for you to process specific things to a function or asset

eternal needle
#

you're going to iterate over it anyways

#

the difference would be your flash bulb would do.. (pseudocode)

if myString[i] == '.'
  flash

compared to

if myCodeList[i] == CodeEnum.SomeValue
  flash
#

its a more defined way rather than using magic strings in every object that needs to translate the code into action

green copper
#

trying to decide how to structure the message enum

scarlet aspen
#

Do you prefer visual studio or visual studio code for programming unity?

green copper
#

I use VS for Unity, VSCode for Web

rocky canyon
#

i use whichever one i see first

eternal needle
# green copper

im not really sure what im looking at here. your enum would literally just define the different morse code characters and thats all.
then you have a list of enum

rocky canyon
#
public enum MorseSymbol
{
    Dot,        // Represents a short beep or signal
    Dash,       // Represents a long beep or signal
    LetterSpace, // Space between letters within a word
    WordSpace    // Space between words
}```
rich adder
#

ya was also thinking something like that

    public enum MorseCode { Dot, Dash, } //etc..
    void Method(List<MorseCode> code){
        foreach (MorseCode codeItem in code){
            ProcessMorseCode(codeItem);
        }
    }
    void ProcessMorseCode(MorseCode code){
        switch (code){
            case MorseCode.Dot:
            //etc
                break;
            case MorseCode.Dash:
            //etc
                break;
        }
    }```
green copper
#

*oHHhhhhh * I see what you mean now

I thought you were saying to store the message itself as an Enum for passing between the archive of dialogue crap and the output boxes

rocky canyon
#

nah, use it as building blocks

#

to construct ur message/code

green copper
#

the only thing still missing then is I need a function to let me write dialogue in ASCII and the code translated it to morse for me, I know how to write the function itself but I'm not sure where that script should live, because it'll need to be accessed and send information to multiple objects

rocky canyon
#

oops added that to my project 😄 , i dont need morse code in my project

scarlet aspen
#

How do I get the Intellisense to finish the string or see the two options with the keyboard? sorry for the crappy question

rocky canyon
#

up and down arrows

green copper
#

tab and up/down arrow keys

eternal needle
shadow rain
#

How could i check if the player stops walking?

rocky canyon
#

check the velocity.

#

or if no inputs

shadow rain
#

so if velocity.x ==0 then

#

or smth like that

rich adder
#

controller.velocity.magnitude

rocky canyon
#

what if they're side strafing?

shadow rain
#

idk

scarlet aspen
green copper
rocky canyon
#

if u want a list of keycodes.. finish the first part

#

KeyCode

#

then hit .

rocky canyon
#

oh yea that too ^

#

probably confusing ur ide a bit

scarlet aspen
#

Yeah I'm new sorry lmao, I'm just taking time to how to navigate on IDE

rich adder
#

@shadow rain
you can also do for efficency. But Velocity mag is fine
var sqMag = controller.velocity.sqrMagnitude
if ( sqMag <= minDetectedIsStopped * minDetectedIsStopped)

rocky canyon
scarlet aspen
rocky canyon
#

sometimes u just need to help it along the way

#

make sure to assign it to something tho...

GetComponent<> by itself doesn't do anything

#

MasterMouse theMouseThing;

theMouseThing = gameObject.GetComponent<MasterMouse>();```
scarlet aspen
#

Ah that's why I was looking for a way to make the “major” and “minor” symbols due to the fact that I'm using an American keyboard on Italian layout (spaghetti) and I can't make the symbols... I might as well use the American layout

final kestrel
rocky canyon
#

ahh yea. i mean thats a solid solution..

#

just gotta clean up the mess thats left over lol

#

MasterMouse.Instance.HideCursor();

#

i had soooo many problems like ur describing

rocky canyon
#

where third party assets would take my cursor over

#

and all that crap

#

had to go in and find each and every script that tried to do it.. and jot down which ones should really control it

#

so my gamemanager was that puzzle piece... only the gamemanager can lock /hide/ confine the cursor.. and to do that it has to tell the MasterMouse (my cursormanager) to do it

final kestrel
#

Yeah its a mess for me. Trying to find whats causing it.

shadow rain
#

wait how could i check if the player is even moving

final kestrel
#

My game takes around like 15-20 minutes to complete. So I figured forcing it in update would be okay.

verbal dome
shadow rain
#

i thought i only needed when to check if the player stops moving but i actully need the opposite

verbal dome
#

Same thing but you invert the condition

#

Instead of velocity.magnitude < you'd use velocity.magnitude. >

#

Or just read your inputs directly

rocky canyon
#

if cc.velocity.magnitude < reallySmallValue or.... ☝️

#

depends on ur controller.. mine is apparently finnicky.. my magnitude kinda bobs there at the end. b/c i have momentum coded in..

#

in my case i'd want to check the inputs instead

verbal dome
#

If this is about animations then using the input is probably the best so the player gets instant feedback when they start/stop moving

rocky canyon
#

yea ^ i like snappy

shadow rain
#

that ok?

verbal dome
#

Yes, as long as you have set up the animator side properly

#

You can also do something like animator.SetFloat("Speed", velocity.magnitude)

shadow rain
#

alr

verbal dome
#

If you don't just want 0 or 1

shadow rain
#

what should the animator side be like

rocky canyon
#
        //velocity method
        if(characterController.velocity.magnitude > 0)
        {
            //we must be moving
            isMoving = true;
        }
        else
        {
            //we aint
            isMoving = false;
        }

        //input method
        if(verticalInput <= 0 && horizontalInput <= 0)
        {
            //we aint moving
            isMoving = false;
        }
        else
        {
            //we are (or rather, should be)
            isMoving = true;
        }
rocky canyon
rich adder
# shadow rain

this would be easier with linking a float and using the blend tree

shadow rain
#

is it ok that

analog drift
#

Hey guys a quick question. Is there anything that I need to pay attention when I am importing assets such as veichles or maps that were made originaly in unity 20xx for example and I am using unity 60xx?

rocky canyon
#

oh she'll let u know

shadow rain
#

it just goes straight to the walking animation

rocky canyon
#

well that means the condition tied from idle to walking was triggered

#

or there simply isnt one

analog drift
rocky canyon
#

if no errors.. u should be gucci

#

i cant see why it would matter..

#

its not like fbx formats have changed

#

now if they have scripts attached yes

analog drift
#

Ok ok, just need a few simple vehicles and a map to test it on

rocky canyon
#

you'lll probably need to refactor

#

lots of functions have been deprecated since then..

#

if u run into any of those its easy enough to google to find the alternative method

#

or ur IDE will tell u

shadow rain
#

conditions

#

idk

analog drift
rocky canyon
# shadow rain

umm.. thats the same condition is not?

if a number is greater than 0.. it can also be less than 1

#

every number from 0 - 1 in fact

shadow rain
#

oh

#

yeah

rocky canyon
#

lol

#

math is hard..

shadow rain
#

no but it just goes straight to the walking anim

shadow rain
#

i swear

rocky canyon
#

ya, b/c the condition that sends it to idle.. is also true to send it to walking

shadow rain
#

ooh

#

alr

#

what should i do

rocky canyon
#

it should go to idle from entry w/o a condition..
the only conditions should go from idle to walk and then walk to idle...

idle to walk would be if > 0 and from walk to idle would be if < really small number

#

try that ^

#

if > small number.. if less than small number

#

i use booleans.. so im not 100 percent sure

#

a Blend-tree would be hella useful like Nav mentioned a while back

#

do u use Raw inputs or smoothed inputs?

#

b/c if its smoothing.. thats probably causing the issue..

#

b/c it slowly ramps up from 0 - 1

shadow rain
#

idk

rocky canyon
#

DEADZONE

#

is what u need

shadow rain
rocky canyon
#

if var > 0.1f -> walking

shadow rain
#

that it or am i thick?

rocky canyon
#

if var < 0.05 -> idle

#

if u make a little deadzone it shouldnt re-trigger the walk instantly

shadow rain
#

alr so

#

is that right

#

ill change it in a minm

rocky canyon
#

if speed > 0.1

shadow rain
#

to what u js said

rocky canyon
#

yea.. just test and see

#

its all about trial and error when u learning

shadow rain
#

what abt the other one

rocky canyon
#
if (speed > 0.1f) // Prevents instant re-triggering
    animator.SetBool("IsWalking", true);
else if (speed < 0.05f) // Ensures it fully settles before switching back
    animator.SetBool("IsWalking", false);```

this is how i usually do it.. i control the bool in code.. and just use bool as transitions
#

idk my brain is starting to hurt lol

shadow rain
#

alr thats prolly easier tbh

rocky canyon
#

the simplest thing would to be to go off ur inputs

#

if 0 if 1.. only two states it could ever be in

#

unless ur using Input.GetAxis <- b/c this one has smoothing

#

Input.GetAxisRaw does not..

#

its either -1, 0 or 1

#

The problem was that both transition conditions were true at the same time because every number between 0 and 1 satisfies both conditions.

shadow rain
rocky canyon
#

now just use that (1) bool for ur transitions

#

fun fact: theres always a dozen ways to do a single thing..

#

disclaimer: my thing may not be the best thing

#

😅 lol

shadow rain
#

else says it needs a ;

rocky canyon
#

where did u put that?

#

needs to be in an update() loop or something

shadow rain
#

it is

rich adder
#

is your ide configured?

shadow rain
#

got it

rich adder
#

that should be underlined red

rocky canyon
#

show full, works fine here

rocky canyon
shadow rain
#

just goes straight to walking

rocky canyon
#

(╯°□°)╯︵ ┻━┻

#

i give up sorry lol

shadow rain
#

yeah no worries

rich adder
#

have you tried debug logging the value of speed

shadow rain
#

no.

rocky canyon
#

this is a case where i should just use properties right?

rich adder
# shadow rain no.

well you should always "record" the actual values in console so you verify whats going on behind the scenes

rocky canyon
#

like a public get private set

rocky canyon
verbal dome
rocky canyon
#

i mean via the script

#

not externally no

#

not sure why i did it this way.. i think its b/c i didnt want to expose the private variables

#

but i still needed to be able to read them elsewhere from time to time

#

i just noticed how ugly and offputting it looks

#

or maybe thats just me lol

rich adder
#

only difference I would still use Is prefixed to the bool so I know for a fact its boolean, but thats preferences

shadow rain
#

wait ik y

#

its bc my speed is a set value

rocky canyon
#

wait a minute!

shadow rain
#

i dont think it can go to zero

#

its always set at 3

rocky canyon
#

whats teh difference between public bool Grounded() => characterController.isGrounded; and public bool Grounded => characterController.isGrounded;

rich adder
#

weren't you reading from magnitude or did I miss something ?

rocky canyon
#

they use speed

rich adder
shadow rain
#

ok right

rocky canyon
#

they do the same thing tho right?

shadow rain
#

so what now

rich adder
#

method is using expressionbody ?

#

i think is called (i always forget)

rich adder
rocky canyon
rocky canyon
#

thanky 👍

shadow rain
#

what should i change

#

like speed to velocity.magnitude?

rocky canyon
#

have u debugged the values again?

shadow rain
#

dont think so

rocky canyon
#

yea.. speed needs to = velocity.magnitude

rich adder
hollow dawn
rich adder
analog drift
#

Guys from experience most of the assets on unity store are for built-in render pipelines? Is there a way to tell because I imported one and everythings pink and I have URP

hollow dawn
#

Just wanted to know how I can make movement relative to the camera?

rich adder
#

matching the camera you would need to pass the forward to the rb moverotation then

hollow dawn
rich adder
#

its kinda backwards thats why I was confused on that

mystic anvil
#

So I started learning Scenes and here I am checking if there is a next scene or not. I think I did it right, I just don't know how to get the length of the scenes.

polar dust
shadow rain
#

should tht be my variable or whatever @rocky canyon

hollow dawn
polar dust
#

i imagine most assets use BIRP as theres no real reason not to (unless its specifically for HDRP), plus it makes the asset more accessible as not every developer will be using URP

rich adder
#

but keep it locked to Y only

polar dust
#

@analog drift under the edit menu, this is what you want to click

mystic anvil
analog drift