#๐Ÿ’ปโ”ƒcode-beginner

1 messages ยท Page 271 of 1

wraith valley
#

Is it because of older version?

rocky canyon
#

how what? and why do you have the prefab in the scene?

polar acorn
#

how what

rocky canyon
#

your pipespawner should be the thing that puts copies of it in the scene

wraith valley
#

Text changer

#

I did like he

rocky canyon
#

i thought u had it working? why is it not working now

wraith valley
#

Yes

rocky canyon
#

do u remember 20 minutes ago us helping u modify the code to work better?

wraith valley
#

Yes

rocky canyon
#

we didn't follow along with that video.. soo its bound to be a bit different now

sullen trench
#

im sorry, im not familiar with iirc ๐Ÿ˜ตโ€๐Ÿ’ซ . but alot of my confusion comes from whenever i make a .jslib to go into my plugins folder, i get this thingy for my inspector

twilit ocean
#

how do I change it tbh. I'm trying but it can't convert the quaternion properties to RB.

wraith valley
#

A bit different because that`s 2019?

polar wasp
#

after a week on khan academy i am finally able to understand math in unity pain

sullen trench
#

would you perhaps have a link to this read?

polar acorn
wraith valley
#

This

polar acorn
sullen trench
twilit ocean
#

@rich adder https://hatebin.com/rqlizjnuwq I think the only line that needs to change is line 39 right? Since it's the one that really changes the movement of the hammer. And controls how it moves.

#

I identified the RB's existance but I don't know how to properly apply it

wraith valley
vocal marlin
#

do you guys think i should do a different script for attacking vs movement?

polar acorn
#

I cannot see your screen

wraith valley
rocky canyon
#

they look identical to me

vocal marlin
polar acorn
#

you sent a screenshot that says "how" and provided no context

summer stump
# vocal marlin ok ty

Make things as modular as you feel comfortable. More scripts is better than mega scripts

rocky canyon
#

more scripts with good names ๐Ÿ‘

vocal marlin
#

how would i do it if i only want the player to move if they arent attacking?

rocky canyon
#

if u get passed 1k lines. start to reconsider what ur doing

vocal marlin
rocky canyon
#

good, good lol

rich adder
wraith valley
#

Working now

sullen trench
#

Does anyone know if there's away to search these channels with some search bar so i dont have to skim for say, javascript mentions?

rocky canyon
#

im going to play some video games lol..

rich adder
#

the forum you will probably find better info

rocky canyon
#

keywords search is all u got here

#

181 results for jslib ๐Ÿ™‚

sullen trench
#

@rich adder @rocky canyon thank you guys

rocky canyon
#

good luck ๐Ÿ€

twilit ocean
scarlet skiff
#

im still at this, verified that its the animator causing this, where do i go from there?
And also the script with the flip method is attached to a empty parent for the characters sprite, again it used to work but suddenly it doesnt

rocky canyon
#

thats not a problem with rb.rotation.. thats a problem with ur syntax

rich adder
#

try MoveRotation instead

rocky canyon
#

lol i read MoveRotation when i read it

twilit ocean
rocky canyon
#

yes, Function*

rich adder
#

its not a class

#

its a method

twilit ocean
#

oops

rocky canyon
#

it uses a quaternion..

rocky canyon
#

nvm it uses an angle.. 2d*

rich adder
#

oh yea

#

wait

rocky canyon
#

need some conversions

rich adder
#

oh yeah looking at my script again

#
arm.MoveRotation(Mathf.LerpAngle(arm.rotation, zRot, speed * 100 * Time.fixedDeltaTime));```
#

im using float

#

opsies

#
 dir = (mouseWorldPos - arm.transform.position).normalized;
 zRot = isInverse ? Mathf.Atan2(dir.y, -dir.x) * Mathf.Rad2Deg : Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;```
rocky canyon
#

mine too.. why u still using rb.rotation?

rich adder
#

start angle?

twilit ocean
rich adder
#

if you see earlier I corrected mysellf

vocal marlin
rich adder
#

2D does not need quaternion for rotation , its float

#

you have to get the angles in degrees

#

I showed you example how I did mine @twilit ocean

swift crag
#

rb.rotation is a single float. 2D rigidbodies can only rotate around one axis.

twilit ocean
hot anvil
#

i feel so dumb i am making my very first project and i cant figure out how to make my game end/go to win screen when i make it to my object (just making a basic platform but trying to learn stuff as i go) can anybody help with a working script that i could study?

rich adder
#

execept for the rotation part

#

Mathf.Atan2 * rad2D to get the angles then pass them in the Lerp (you have this already)

swift crag
#

note that Mathf.Lerp will not be appropriate here. It won't correctly handle how angles wrap around when they pass 360.

#

fortunately, there's Mathf.LerpAngle to replace it

rich adder
#

yup thats what im doing now, but my lerp is wrong
this is 2 year old code :p

arm.MoveRotation(Mathf.LerpAngle(arm.rotation, zRot, speed * 100 * Time.fixedDeltaTime));```
swift crag
#

I would suggest using Mathf.SmoothDampAngle or Mathf.MoveTowardsAngle for more consistent behavior

#

The former is good for reaching a target in a fixed amount of time. The latter is good for moving at a fixed rate.

twilit ocean
twilit ocean
rich adder
#

i just showed you that we had the same exact code for angles

#

the reason why its confusing is transform.rotation uses quaternions

#

rigidbody2D has no rotation methods with quaternions its floats (angle is only 1 axis here)

twilit ocean
#

So ok lemme get this straight. All I need to change is the last line that sets how the hammer moves correct?

#

Using the Mathf.LerpAngle method?

rich adder
#

if you want more accurate simulation of phyisics

rich adder
#

btw these are just to make it smooth going from one rotation to another

swift crag
#

to make sure I'm up to speed here

#

the hammer was being moved by setting transform.rotation

rich adder
#

yea

swift crag
#

this was causing physics issues because this was bypassing the physics system

misty coral
#

How do i not change the scale

rich adder
misty coral
rich adder
#

you can also make a 1,1,1 object to parent to thats child /sibling i think

swift crag
#

i'm surprsied that isn't a compile error. does float implicitly convert to Vector2...?

#

no, it doesn't

#

oh, I see there's another compile error

#

those arguments don't make any sense

#

MoveTowardsAngle takes three arguments:

  • The current angle
  • The target angle
  • The maximum change
#

they're all out of order and direction doesn't make sense at all here

rich adder
#

brt just changed my old one to

  arm.MoveRotation(Mathf.MoveTowardsAngle(arm.rotation, zRot, speed * 100 * Time.fixedDeltaTime));``` is this correct lol seems the result is same so tis not broken at least
swift crag
#

speed * 100 should just be speed, where speed is the maximum angular velocity (measured in degrees per second)

radiant frigate
quiet scaffold
#

Cannot instantiate objects with a parent which is persistent. New object will be created without a parent.

Instantiate(dmgNumberText, enemyPos, Quaternion.identity, GUI.transform);
radiant frigate
slender nymph
swift crag
#

did you put the canvas in DontDestroyOnLoad?

swift crag
radiant frigate
swift crag
#

it's speed degrees per second

quiet scaffold
swift crag
#

if you want it to be faster, make it faster

rich adder
#

oh right

#

im dum

supple zealot
#

does anyone know how i could manage to get game elements outside the game? id like to create a small launcher before the game boots

twilit ocean
swift crag
slender nymph
swift crag
#

you wouldn't use a string that says "he's over there!" to calculate the angle to move to, now would you? :p

swift crag
radiant frigate
swift crag
#

GUI is probably a reference to a prefab. You need a reference to an actual thing in the scene.

rich adder
#

oh yeah much better lol

swift crag
quiet scaffold
swift crag
#

Instantiating it doesn't change what the variable refers to.

#

It just creates a new instance of whatever the variable refers to.

slender nymph
swift crag
#

Then use Mathf.MoveTowardsAngle to figure out what rotation to give your rigidbody.

twilit ocean
twilit ocean
slender nymph
# radiant frigate ty!

alternatively, if you are just trying to make it bounce you can just use a physicsmaterial2d that has a higher bounciness

swift crag
#

by definition, that is the current angle

misty coral
# rich adder oh yeah much better lol

i cant actually find any tutorial videos on how to use parent constraints, and I don't really understand how to use them from Unity documentation... Do you know any tutorials or anything?

radiant frigate
swift crag
#

This is the page you're reading?

rich adder
twilit ocean
# swift crag `rb.rotation`

wait what I put that there. Wow that's surprising I thought it would be wrong because "yes".

So property 1 and 2 are correct right? Angle is the current mouse calculated angle and rb.position is the angle of the rb (ofc)

swift crag
#

no, rb.rotation is the rotation of the rigidbody

final kestrel
#

https://hatebin.com/yuszijpoun I have this script that teleports player to the destination position which is just behind the door object. I made the door a prefab with destination empty. I assign the destination on the inspector. However when there are two doors. I come out of the first door's destination. I assign them seperately in the inspector why is this happening?

swift crag
#

rb.position is not the rotation of the rigidbody

twilit ocean
swift crag
#

This finds an FPETeleport...somewhere

twilit ocean
swift crag
#

Are you sure there's exactly one of them?

final kestrel
swift crag
#

well, here's the thing..

final kestrel
#

It works fine if there is one single door

swift crag
#
if (_playerTeleport.isPlayerInRange && Input.GetKeyDown(KeyCode.E))
        {
            StartCoroutine(_playerTeleport.StartTeleport(_destination.position, _destination.rotation));
        }
#

Both teleporters run this code.

#

Both of them try to teleport the player.

#

The player should ask the FPETeleporter to do the teleportation.

#

That way, the player can look for a nearby teleporter (maybe using Physics.OverlapSphere to hit a trigger collider) and ask it for a teleport.

twilit ocean
# swift crag Yes.

So all that's left is the Maximum rotation. How do I set the maximum rotation? Maybe 360 would be it?

final kestrel
#

So teleporters should not run this code. Instead player should do the teleportation

swift crag
#

This code is in FixedUpdate

#

360 will cause you to rotate by up to 360 degrees every physics update.

twilit ocean
#

oh...

#

that's not good

swift crag
#

The teleporters shouldn't need to find a FPETeleport component and shouldn't be checking for player input

twilit ocean
#

It should be called minimum rotation at that point ,_,

misty coral
# rich adder `rb.position` still wrong

I think this might not be the right solution for my problem, I have a platform that can move, and I made it so the player moves with the platform, but when the player stands on the platform, its capsule becomes really skinny

#

idk why i replied to that

swift crag
#

The solution is to not do that.

misty coral
#

huh

swift crag
#

One option is to rearrange things a bit

gleaming kraken
#

i have a question, why not just do


transfom.position.x = -10```

in the if statement?
misty coral
#

oh

swift crag
#
  • Platform <-- not scaled; you're parented to this
    • Visual <-- scaled
misty coral
#

wait i think i get it

swift crag
#

transform.position is a property

#

It calls a method when you access it.

#

The method returns a Vector3

gleaming kraken
rich adder
#

huh couldve sworn the parent component had a way to not inherit scale option

#

weird..

swift crag
#

Vector3 is a struct -- it's a value type. When you have a Vector3 variable, it's literally just 3 floats glued together. It's like an int or a bool in that you don't store a reference to it

gleaming kraken
#

would it not work in the code itself?

swift crag
gleaming kraken
#

ah okay

swift crag
#

that's a reference type

#

Value types are never shared. They're always copied.

#

So transform.position returns a Vector3

vocal marlin
#

In my game there are two 'modes' (I don't know what else to call them) the player can be in, Overworld and Battle. I only want the player to do 'battle' actions such as attacking when they are in battle mode and 'overworld' actions when they are in overworld mode, and I want the controls to change accordingly. I've heard you can do this witht the new input system, but I'm not fully sure how.
This is what i've done so far

swift crag
#

Nobody else can see that Vector3, because it's a value type.

#

Assigning to one of its fields would be completely pointless.

#

You'd be modifying a Vector3 that nobody else will ever see

#

Thus, you get a compiler error.

#

There's no point in doing it, so if you do it, something must be wrong.

gleaming kraken
#

I see

swift crag
#

Now, you can read from a field just fine

gleaming kraken
#

that makes more sense, thank you

swift crag
#

you're reading a value from the copy

twilit ocean
swift crag
#

ParticleSystem.MainModule is a struct

#

It's a struct full of properties that, when set, call some code to actually modify the particle system

#

So in theory, this would work just fine

#
ps.main.startDelay = 1f;
#

It'd correctly call a method that would go tell the particle system to change its settings

gleaming kraken
#

so 1.0f

swift crag
#

no, floats do not need a decimal point

#

1f is a literal of type float

rocky canyon
#

1f == 1.0f

gleaming kraken
#

oh

swift crag
#

1 would also be fine. integers can implicitly convert to a float

swift crag
swift crag
#

(in FixedUpdate, Time.deltaTime is set to be Time.fixedDeltaTime, so you can use either)

#

By default, Unity runs physics 50 times per second

#

So Time.fixedDeltaTime will be 0.02 (as will Time.deltaTime inside FixedUpdate)

#

If you want to rotate by 360 degrees per second, you must rotate by 360 * 0.02 degrees per physics update.

#

this works out to 7.2 degrees per physics update

#

360 * Time.fixedDeltaTime does the trick

twilit ocean
#

My brain is legit burning cryingriversbro

Ok, if I got it all right, putting 360 * Time.FixedDeltaTime will make it work?

swift crag
#

Using that for the maxDelta argument will let the rotation change by up to 360 degrees per second.

twilit ocean
#

so this?

swift crag
#

That looks reasonable, yes.

twilit ocean
rich adder
twilit ocean
vocal marlin
swift crag
rich adder
swift crag
#

non-uniform scaling causes skewing when a child object rotates

#

The child experiences scaling in varying directions as it rotates.

rich adder
#

make the hammer head child of player and attach it to hammer with a fixed joint

twilit ocean
swift crag
#

or just parent the various visuals to a single object

#

avoid parenting something to a non-uniformly scaled transform

rich adder
#

using fixed joint . legs too long or arm not long enough UnityChanLOL

twilit ocean
swift crag
twilit ocean
#

Instead of 2 separate collisions boxes?

swift crag
#

a rigidbody uses all colliders parented to it.

twilit ocean
swift crag
#

Whatever's easier to implement.

ionic zephyr
#

if I am trying to each of my characters to have a different hability (like an smash attack in smash) how could I face that?

twilit ocean
#

I guess 2 colliders might also make it less capable of going through objects since it checks twice in overlapping points.

#

At least in my ooga booga logic (more equal good)

ionic zephyr
sullen trench
#

@rich adder @rocky canyon update Solved ๐Ÿฅณ Thanks for the tips. All in the search tool.

rocky canyon
#

in here? nice

digital pier
#

anyone know of any 1 on 1 tutoring services for Unity?

rocky canyon
#

more financially viable to teach yourself

#

many many tutorials both text and video format

twilit ocean
#

Thanks for all the help till now @swift crag @rich adder. The current state is still a little glitchy and I'm not sure why, since all calculations are being made in Rigid Body now.

#

I'm just thinking that we've been here for so long bcs I'm quite dum when it comes to coding.

rich adder
twilit ocean
#

ahhh the recording is all chopped

rich adder
#

fixed joint goes on the hammer head with rigidbody and collider

#

I put my Mass probably too high, but you get the point

rocky canyon
#

heard of this plug-in? i cant seem to get it to work.. or idk how to trigger it

rocky canyon
#

ahh thats the one u were talkin about earlier

grizzled zealot
#

Is there a way to show this in the Inspector? Somehow the inspector doesn't show things computed with =>. The original objecti is not serializable.

rich adder
grizzled zealot
#

Even adding [SerializeField] will not show the fields in the inspector.

rich adder
#

maybe they disabled it

twilit ocean
rich adder
rich adder
languid spire
#

and [Header] only works immediately before a serializabe displayed field

grizzled zealot
#

But doesn't [field: SerializeField] work for properties with simple setter/getters ?

languid spire
#

yes, which is not the case here

rich adder
grizzled zealot
#

Is there a way to show a general ToString() in an inspector?

twilit ocean
grizzled zealot
#

Basically, I have my own custom class, but want the inspector to show property.ToString()

rich adder
#

so its locked to player

#

the arm hammer should have the Hinge joint to player, then hammer head is fixed joint to arm of hammer

twilit ocean
#

So removing the pivot you say?

rich adder
#

so it swings attached to player rb

#

and also affects it

twilit ocean
#

What should I replace?

rich adder
twilit ocean
#

Pivot is a game object

#

I can't replace a game object with a component

rich adder
#

if you attach arm hammer with joint you dont really need pivot

#

hinge is the pivot

twilit ocean
#

This then ?

rich adder
twilit ocean
#

Cant wait to see what will happen

rich adder
#

should be something like this

rocky canyon
rich adder
#

also its more like copilot than intellicode

rocky canyon
#

true, but thats the rabbit hole i found that wasnt blocked ๐Ÿ˜„

rich adder
#

do let me know if the results are decent with it

proven fable
#

Man someone among u op guys take me under u and train me ๐Ÿ’€

eternal needle
rocky canyon
#

you probably couldn't afford it

rich adder
#

too much work

twilit ocean
rocky canyon
#

learning urself and reaffirming things in this discord is ๐Ÿ†“

proven fable
rocky canyon
#

make it have more umph

twilit ocean
rich adder
rocky canyon
twilit ocean
rich adder
# twilit ocean

you are probably moving using Velocity instead of addforce maybe ?

#

that might override any external forces

rocky canyon
#

ya, ^ tahts true..

twilit ocean
rich adder
#

yup

#

I move using AddForce so i probably why my player gets affected

#
 private void FixedUpdate()
 {
     rb.AddForce( Vector3.right * (input.x * moveSpeed));
 }```
rocky canyon
#

if i want an interactable to be highlighted/hover or w.e when lookin at it whats the best setup for that?
should i do that thru the raycaster (pov object) or tell the interactble to do that.. and then should it be an interface if its going to have a couple of interacted effects

rich adder
rocky canyon
rich adder
rocky canyon
#

i think i know how imma do it.. just its the same ole thing i always do

rich adder
#

Interface is good

#

might be able to even levarage the ones already built in Event System with the IPointerHandler

#

using 3D physics raycaster on cam

rocky canyon
#

holy crap i cant figure out how i call these events

#

VStudio wont tell me or idk how

twilit ocean
rich adder
#

not sure why you did that

#

but yea ig

rocky canyon
#

ahh i figured out out..

#

had to find the interfaces references

twilit ocean
#

oh yeah that's because I changed it to a vector2 for a moment ("dirX.x" really?), but then I would have to change other things and realized I didn't had to do that.

rich adder
#

well no even dir would not make sense to me

#

I make it v2 because usually do

 input.x = Input.GetAxis("Horizontal");
 input.y = Input.GetAxis("Vertical");```
#

you dont need vert, so you could just do horizontal = or w/e

#

also get ur inputs in Update and pass them in FixedUpdate

twilit ocean
honest vault
wintry quarry
honest vault
wintry quarry
#

Wouldn't the bullet just damage whatever it hits? Why does it need a direct inspector reference to the enemy?

rich adder
#

why is bullet referencing specific enemy?

wintry quarry
#

Get the reference in OnTriggerEnter2D or OnCollisionEnter2D.

honest vault
#

becuz i wanted to test smthn like when the bullet collides it destroys the game object but it ended up destroying both the player and the enemy

#

i might just change it so it gets a certain tag then destroy

rich adder
#

it was probably colliding with player and you weren't checking specific object maybe?

quick ruin
#

How do I use transform.LookAt without changing the x and z rotation?

#

I would like to lock the x and z but clamp doesnt work

rich adder
swift crag
#

That will still overwrite your existing pitch.

#

well, that's backwards, too :p

rich adder
#

ah yea

swift crag
#
var pos = target.position;
pos.y = transform.position.y;
transform.LookAt(pos);
rich adder
#

been a while ๐Ÿ˜…

swift crag
#

But that's going to change your pitch and roll

swift crag
#

without any up/down pitching?

swift crag
quick ruin
#

Thanks will try implementing one moment

native vortex
#

I followed a tutorial and now have a working tic tac toe game, yay! I followed another tutorial and now have a working restart button, woohoo! I'm now really lost on how to write a script to check for winner . Is there anyone who can help me? I'm completely new to game dev, unity and programming.

swift crag
rich adder
honest vault
swift crag
#

check each row, column, and diagonal to see if all three tiles have the same mark in them

native vortex
honest vault
eternal falconBOT
#

:teacher: Unity Learn โ†—

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

rich adder
#

when I mademine a while ago I had an enum (X, O, none)

honest vault
#

helped me a ton

rich adder
#

then checked with looping the grid

native vortex
swift crag
#

I presume you've already implemented the tic-tac-toe game.

rich adder
#

you can even use a 2D array

native vortex
#

Yes I have and it actually works lol

rich adder
#

so you're just looping through each colum and row

swift crag
#

It might help to write a method that gives you every possible line through the board.

#

It would look a little bit like this.

native vortex
#

How do I do that? Is there a tutorial you recommend for that?

swift crag
native vortex
swift crag
eternal falconBOT
twilit ocean
#

Tried to do something similar for the jump but it didn't work out

foggy lion
#

How do I detect when two colliders with two different tags are colliding.

rich adder
native vortex
#

I'm sorry for all the questions and appreciate all input

rich adder
native vortex
#

Putting my son down for a nap, gotta step away for a bit. Thank you all again

swift crag
# swift crag It would look a little bit like this.
public IEnumerable<List<Vector2Int>> GetLines()
{
  for (int row = 0; row < rows; ++row) {
    List<Vector2Int> rowLine = new();

    for (int col = 0; col < cols; ++col) {
      rowLine.Add(new Vector2Int(row, col));
    }

    yield return rowLine;
  }
}

This method would give you every combination of grid squares that form a winning row. You could then also add columns and diagonals in a similar way. Given this, you could see if any line has the same mark in every single cell. If you find one, that player wins.

#

You could also just write them out by hand, I suppose

swift crag
#

but I'd rather automate it (what if I want to do 5x5 tic-tac-toe?)

foggy lion
# rich adder OnCollisionEnter

Right I know about that, but my object uses colliders that are childeren, with tags. I want only certain parts of those childeren to interact with another object that has a tag.

rich adder
twilit ocean
rich adder
#

thats linked to up arrow / W-S key

#

if you're not holding it then your value is 0

#

whats any number * 0 ?

rich adder
#

or do you mean just colliders ignoring eachother

foggy lion
#

I feel like its hard to explain without just showing you what Im doing

rich adder
#

make a video

foggy lion
#

Good idea

ionic zephyr
#

why is it Type Mismatch if I am introducing a png?

#

it requires a Sprite but isnt this type of image ?

swift crag
#

Show the inspector for that asset.

#

the "PharaohSpr..." one

ionic zephyr
swift crag
ionic zephyr
ionic zephyr
#

this is what it asks me for

swift crag
# ionic zephyr

yes -- I'm looking for the full inspector for whatever this is clipped from

ionic zephyr
#

sorry, I am not understanding what you want me to show you

ionic zephyr
#

it is an scriptable object

foggy lion
#

Hopefully this gets my issue across

sage mirage
#

Hey, guys! I have a small issue with a game mechanic I want to implement. So, whenever my player reaches +10 score to increase speed of moving elements which are background layers, ground layers and tree logs prefab slightly. For one reason, my tree logs prefab doesn't increases the speed.

swift crag
#

i just tried doing that myself

ionic zephyr
swift crag
#

importantly, is there more than one sub-asset in there?

#

it ought to look something like this

ionic zephyr
ionic zephyr
swift crag
#

there's only one sub-asset here

ionic zephyr
#

oh yeah sorry

#

one sub asset

ionic zephyr
quick ruin
#

if value a = 60 so value b = 0, how do I make value b go up to 30 if value a goes to 0?

swift crag
#

Did you try dragging this sub-asset into the field?

swift crag
ionic zephyr
swift crag
#
float t = Mathf.InverseLerp(60, 0, a);
b = Mathf.Lerp(0, 30, t);
swift crag
swift crag
ionic zephyr
swift crag
#

If the third argument equals the first argument, it's zero, and if the third argument equals the second argument, it's 1

#

and it's linearly interpolated in between

swift crag
ionic zephyr
swift crag
#

Is this EntityData object also an asset?

#

i.e. you used the create asset menu to make an instance of it in the project window

rich adder
ionic zephyr
swift crag
#

Yes.

ionic zephyr
#

the strangest part is that when I assign the image in the gameObject directly it works

swift crag
#

you mean when you assign it to a SpriteRenderer's sprite field?

ionic zephyr
#

yeah

swift crag
#

just to make sure

ionic zephyr
#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

[CreateAssetMenu(fileName = "New Character", menuName = "Character")]
public class EntityData : ScriptableObject
{

#region CharacterStrings
public string Name;
public string Description;
#endregion
#region Sprites
public Sprite CharacterSprite;
public Sprite BulletSprite;
public Sprite ShieldSprite;
#endregion
#region damageParameters
public float meleeDamage;
public float bulletDamage;
public float bulletSpeed;
public float punchDuration;
public float ammo;
#endregion
#region moveParameters
public float moveSpeed;
public float jumpNumber;
public float jumpForce;
public float weight;
public float dodgeTime;
#endregion
#region health
public float health;
#endregion
#region boost
public float MaxBoostQuantity;
public float WhenHitAdd;
public float boostMultiplier;
#endregion
void Start()
{
    
}

// Update is called once per frame
void Update()
{
    
}

}

swift crag
#

okay, so there isn't anything that could be modifying those fields

#

at this point i'd restart the editor and see if it starts behaving properly

ionic zephyr
#

okay lets see

swift crag
#

what version of unity are you using?

fading rapids
#

How do you make it so your player instantly stops when releasing the movement key in 2d instead of deaccelarating till stopped, do you need some kind of code or just change something in the rb

ionic zephyr
eternal falconBOT
polar acorn
ionic zephyr
swift crag
#

I see no reason for a type mismatch to happen here. I guess I'd whack this with the "delete Library and reimport everything" stick at this point.

fading rapids
swift crag
#

close your project, navigate to your project directory, and delete the Library folder

#

you can also delete the Temp folder

#

don't delete anything else (especially not the Assets folder)

#

Reopen the project and Unity will reimport everything. This can take a while.

#

It'll forget which scene you had open, so you'll need to go to file -> open recent

pearl garden
north kiln
#

You would get a type mismatch if the type was previously different. Deleting the reference and reassigning it should be the fix

swift crag
#

hm, yes, i should have suggested clearing the field..

fading rapids
#

So basically I would use if(isGrounded = false && input.getkeydown(horizontal)
{Rb.velocity.x = 0} would this work

swift crag
#

close, but you can't assign to the x field on rb.velocity

#

store the velocity in a variable, modify the variable, and store that back into rb.velocity

ionic zephyr
swift crag
#

no, in the inspector

#

click the field and hit backspace

fading rapids
#

Is isGrounded = false the same as !isGrounded

swift crag
#

== false is

#

= false is not

swift crag
#

since = is the assignment operator

swift crag
fading rapids
#

Oh yh obv

pearl garden
swift crag
#

and then you reassigned something and it went back to "Type mismatch"

ionic zephyr
swift crag
ionic zephyr
fading rapids
ionic zephyr
#

it didnt

ionic zephyr
swift crag
#

Add another field that references, say, a Material. Does that work?

rare basin
#

do you have any errors in the console? @ionic zephyr

ionic zephyr
#

not reallty

delicate pewter
#

Alright I got a question for you guys, I'm stumped.

Right now I'm accurately finding the corners of a rectangle by simply just getting the objects position (center) and just adding half of its x scale and half of its y scale for each corner. So basically for a 2x4 rectangle, one corner is the center position + 1 to x and 2 to z etc. Like so:

            Vector3 size = unityObstacle.transform.localScale / 2.0f; // half size for offset
            Vector3 center = unityObstacle.transform.position;

            // Calculate the corners of the base of the rectangle
            Vector3 corner1 = center + new Vector3(-size.x, 0, size.z);
            Vector3 corner2 = center + new Vector3(-size.x, 0, -size.z);
            Vector3 corner3 = center + new Vector3(size.x, 0, -size.z);
            Vector3 corner4 = center + new Vector3(size.x, 0, size.z);

Simple enough. However, here is the conundrum. When I rotate the object inside the editor. It's x and z scale is still the same obviously, but it's rotated 90 degrees for instance, so it won't work anymore. How can I instead find the corners for any rotation? Best case would be to find a solution that works with any rotation, however I can live with 90* rotations.

swift crag
#

Itโ€™s a type mismatch on an asset trying to reference another asset. Very odd.

delicate pewter
#

Maybe there is a way of doing it the same way, as if it wasn't rotated. Then use some mathematical formula that rotates the whole thing in the code as well?

ionic zephyr
swift crag
delicate pewter
swift crag
#
transform.TransformPoint(new Vector3(-0.5f, 0, -0.5f));
#

This computes the point at [-0.5, 0, -0.5] in the transform's local space

#

the result is a world-space point

#

This will account for position, rotation, and scale.

swift crag
ionic zephyr
#

Oh SHIT

swift crag
#

There it is :p

#

I got fooled by the icon

#

and I was not expecting the assignment to be even permitted in the first place

delicate pewter
#

Hm not sure I follow. The object is created in the Editor not in the script. So the only coordinate I have is just the center position. The four corners I just get through using its .x and .z

But are you saying the .x and .z would be different in world scale?

#

.x .z in scale that is

swift crag
#

You can still do something similar.

#

You can construct a Matrix4x4 from a translation, rotation, and scale. Then you can use it to transform points.

#
var matrix = Matrix4x4.TRS(center, Quaternion.AngleAxis(angle, Vector3.up), size);
var result = matrix.MultiplyPoint(new Vector3(-1, 0, -1));
#

(i forgot you had divided the size by 2 already; i think you can just use [-1, 0, -1] here)

#

and actually -- use MultiplyPoint3x4 instead

queen adder
#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour {

[Header("References")]
public Rigidbody rb;
public Transform head;
public Camera camera;


[Header("Configurations")]
public float walkSpeed;
public float runSpeed;


[Header("Runtime")]
Vector3 newVelocity;


// Update is called once per frame
void Update() {
    newVelocity = Vector3.up * rb.velocity.y;
    float speed = Input.GetKey(KeyCode.LeftShift) ? runSpeed : walkSpeed;
    newVelocity.x = Input.GetAxis("Horizontal") * speed;
    newVelocity.z = Input.GetAxis("Vertical") * speed;

    rb.velocity = transform.TransformDirection(newVelocity);
}

}

swift crag
#

MultiplyPoint3 works for any matrix. MultiplyPoint3x4 works for simpler matrices, including this one, and it's a lot faster

summer stump
queen adder
summer stump
#

And also, for next time, !code

eternal falconBOT
summer stump
#

So yeah, that is the issue

#

Either use MovePosition or set it to dynamic

queen adder
#

ok

iron wind
#

!intellisense

#

whats the command for how to set up ide?

sullen trench
#

I think i saw it earlier

modest dust
#

!ide

eternal falconBOT
sullen trench
#

beat me to it

flint falcon
#

Does anyone have a good tutorial video on coding movement for a 2d space ship that follows the direction of your cursor and buttons for forward and back.

#

Can't seem to find one

rich adder
#

how specific

flint falcon
#

Yeah I'm trying to peicemeal it together but I am a super coding beginner

rich adder
#

get the direction part sorted first

crisp mountain
#

I've been trying to make an object flash white upon collision with a bullet. This code used to do it until I tried to make it better, which failed, and now I've gone back to the old code where it used to work, and it doesn't seem to work anymore. This is the same script where an object is assigned health, loses it, and destroys itself upon running out, which is why the rest of the script is there. Here is the code: https://hatebin.com/bpvnrgeddn

#

does anyone know what is going wrong here?

flint falcon
crisp mountain
#

I know, but the object destruction doesn't always happen

#

only when health is out

rich adder
crisp mountain
crisp mountain
#

The bullets collide fine, the health works perfectly, it just doesn't flash

rich adder
crisp mountain
#

its on and working

rich adder
#

well thats not enough info

#

show the whole inspector

crisp mountain
#

oh sorry

sly heart
#

I have a small game for a small project, i can run the entire game smoothly in unity itself. but once i try to export i get a lot of errors. I myself havent typed the script that gives error, it was already in unity. Does anyone know what the problem is

crisp mountain
rich adder
crisp mountain
rich adder
# crisp mountain

please dont crop, need to see whole inspector / components clearly visible

sly heart
#

No clue, i just made a 3d game. added hdrp and 3 scenes. I havent created this code I think its part of the hdrp import

crisp mountain
#

here you go

rich adder
crisp mountain
#

the color changing is activated in the same collision thing as the health

rich adder
crisp mountain
#

yes...?

#

the issue is that the object is not flashing white upon receiving damage

rich adder
#

i get it

#

but clearly something is being destroyed

crisp mountain
#

that would be the object being shot upon reaching 0 health

#

doesn't destroy itself otherwise, which is why it occurs in the same function

rich adder
crisp mountain
#

i will check?

rich adder
crisp mountain
#

the bullet destroys itself on collision with an enemy in its own script

#

debug log says IEnumerator runs

rich adder
crisp mountain
#

once per hit

#

five total

#

object has 5 health

#

which i might have failed to show that i set in the inspector

rich adder
#

oh wait

#

ur changing the wrong color

#

the material might be white but your Renderer is still red

sly heart
#

script happend to do nothing

#

deleted it all

#

game runs perfect

#

build does too

rich adder
# crisp mountain

should be GetComponent<SpriteRenderer>().color = Color.white; instead

#

you should just cache that component anyway

#

[SerializeField] SpriteRenderer spriteRenderer

crisp mountain
#

trying that

#

works now, thanks! :)

quick ruin
#

how do I set transform.rotation.y to t

rich adder
quick ruin
#

transform.Rotate(0, t, 0); causes it to spin on x and z

#

in Update

rich adder
#

it should only spin on Y

#

are you sure ur pivots are correct?

#

also make sure ur lerp is correct (though should not affect x,z)

mild crypt
#

what is wrong?

rich adder
eternal falconBOT
rich adder
#

make sure to configure your editor first, it will show all the underlines red

#

doesn't seem this is the script with error, or you never saved new changes

mild crypt
#

I saved

#

but I dont know where is misstake

#

the "SerializeField" is no green

#

and things like "Vector" too

rich adder
#

your editor is not configured

#

i just told you

#

configure it with the steps above

quick ruin
#

this causes the x to be 180 instead of 90, any ideas

#

Quaternion rot = new Quaternion(0,0,0,0)

rich adder
#

why are you doing Quaternion rot = new Quaternion(0,0,0,0)

rich adder
swift crag
#

the x/y/z/w components of Quaternion are not euler angles

rich adder
#

quaternions are 0-1 values

swift crag
#

use Quaternion.Euler to construct a rotation from euler angles

quick ruin
#

that explains everything wow

#

ty

mild crypt
#

I did evrything

#

and nothing

rich adder
#

whats "everything" ?

swift crag
mild crypt
#

Visual Studio (Installed via Unity Hub)

rich adder
#

open script from unity

mild crypt
#

WORKS!

#

thanks

#

why its gray?

dreamy urchin
dreamy urchin
#

when you don't use a variable it will result gray

mild crypt
#

so what I must do?

dreamy urchin
#

but it will not cause any errors if you don't use it

mild crypt
#

but I want to use it

dreamy urchin
languid snow
#

Hi, I tried (using a tutorial on yt) to make character movement but it isnt working :(

#

can anyone tell me if theres something wrong here?

#

this is the unity screen, idk if the problem is code or here

eternal needle
languid snow
#

it just not working ๐Ÿ˜Ž (i press awsd/arrow keys and it does nothing)

#

ill search a new tutorial then

#

thanks

#

:)

dreamy urchin
eternal needle
eternal needle
languid snow
#

probably

dreamy urchin
eternal needle
# languid snow uhm... none

well start debugging, but also think about it logically. What code can run based on isMoving? None if its false
How does it get set to true, if the coroutine is running.

eternal needle
dreamy urchin
#

moveSpeed is basically always zero, so if he uses it for the speed it will always result zero, he didn't assigne a value to it

#

ohhhh

#

I didn't see the inspector lol

#

sorry my bad hahahaha

eternal needle
#

just saying, their screenshot also shows its set to 10

idle maple
#

Hi I am working on a pick up and drop object script and I wanted to make it so if I fling the camera before dropping it, it throws the object with the force applied to it but I don't really know how to do this properly yet.
I tried it this way:
Vector3 desiredPosition = holdArea.position + holdArea.TransformDirection(objectOffset);
Vector3 moveDirection = (desiredPosition - heldObj.transform.position);
heldObjRB.velocity = moveDirection * pickupForce * Time.fixedDeltaTime;

and objectOffset is defined like this:
objectOffset = holdArea.InverseTransformDirection(pickObj.transform.position - holdArea.position);

and it wasn't the best solution because it just keeps getting close too my face if I run, what could I do to make it stay more in place on the holdArea?

ionic zephyr
#

how can I face the creation of different habilities in different characters

grizzled zealot
#

Does anyone have an idea why the projectiles are off when shooting at 90 and 280 deg angles? At 0 and 180, the shots are spot on. No clue, because the code is really simple.

worthy merlin
#

Any reasoning why my public variables aren't showing on my scripts. And why they are grey? No errors in the console other than some Syntax errors (I swear I am not ignoring, just ported over the work using UVC to pick back up).

rich adder
worthy merlin
#

Ah, gotcha, I'll fix that up and see if it comes back.

#

yep that was it. Thx!

ionic zephyr
#

how can I do a follow bullet?

rare basin
#

did you try type that in google?

ionic zephyr
#

is there a really good way to face it?

#

I thought of using a character ID

queen adder
#

yo i need help with this

ionic zephyr
#

and depending of it trying one thing or another

queen adder
#

i am setting up multiplayer rn

rare basin
queen adder
#

Yes.

#

Did everything to fix it.

rare basin
#

what exactly

queen adder
#

I rewrote the line. I went to where it said the error was but there was nothing in that line.

#
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using UnityEngine.SceneManagement;

public class ConnectToServer : MonoBehaviourPunCallbacks
{
   

    private void Start()
    {
        PhotonNetwork.ConnectUsingSettings();
    }

    public override void OnConnectedToMaster()
    {
        PhotonNetwork.JoinLobby();
    }

    public override void OnJoinedLobby()
    {
        SceneManagement.LoadScene("Lobby");
    }


}```
rare basin
#

is your ide configured?

rich adder
#

has to be troll, this happened last time too

languid snow
rare basin
#

same tutorial

#

probably the tutorial has wrong code xD

queen adder
eternal needle
rare basin
queen adder
#

how do i find if it is configured

rare basin
#

!ide

eternal falconBOT
ionic zephyr
ionic zephyr
queen adder
rich adder
rare basin
#

again

#

configure your IDE, then you will have your error underlined in red

queen adder
#

I click the link and configure it?

rare basin
#

well, try it and see lol

queen adder
#

alr

eternal needle
ionic zephyr
rocky canyon
#

oh, like an ability?

eternal needle
ionic zephyr
#

for example, my idea is that one of the characters shoots a bullet that follows the target, how can I make that possible only if it is one charcater who is using it

rare basin
#

do you actually read what @eternal needle is writing to you?

eternal needle
#

๐Ÿคทโ€โ™‚๏ธ i dont know if we're being trolled or if i need to go to sleep. all of these recent questions make no sense lol

rare basin
#

ok bro

tall delta
# queen adder ```using System.Collections; using System.Collections.Generic; using UnityEngine...

IDE configuration has nothing do to with this error, as it's unrelated to compilation.
there are many ways to get this error, but an educated guess is that you have your own script called SceneManagement somewhere and the complier is getting confused, that or unity version might be wrong.
try to use a fully qualified name and see if that helps. UnityEngine.SceneManagement.SceneManager.LoadScene("Lobby");

queen adder
#

alr

#

alr

#

error is gone

#

yippe

sly wasp
#

How would I instantiate these objects in a certain range?

I have
public float range = 90;

And here I would like to instantiate that range
GameObject[] gatesTrackEMPTY = GameObject.FindGameObjectsWithTag("gatesTrack");

foreach (GameObject position in gatesTrackEMPTY)
{
Instantiate(gatesTrack, position.transform);
}

summer stump
#

@sly wasp Random.InsideUnitSphere * range

#

I think it's called that

#

Look up tbe docs for Random

sly wasp
#

Iโ€™ll look it up

#

But Iโ€™m just trying to make it in a range, not random

meager raptor
#

does anyone know the reason my units can travel through this building asset i got from unity asset store? what do i need to add in the inspector?

verbal dome
eternal needle
tall delta
# sly wasp How would I instantiate these objects in a certain range? I have public float r...

Itโ€™s kinda hard to understand without more context, but essentially what you need to do is scale a vector.
Something like this:

// get a vector pointing from this object, to the object in question
var directionOfSpawnPoint = (position.transform.position -  this.transform.postion).normalized

// scale the vector to be the correct โ€˜length / rangeโ€™
var pointWithinRage = directionOfSpawnPoint * range;

// get the final position by starting at โ€˜thisโ€™ then walk to the spawn point
var spawnPosition = this.transform.postion + pointWithinRage;

Instantiate(gatesTrack, spawnPosition);

I hope that makes sense ๐Ÿ™‚

verbal dome
meager raptor
verbal dome
#

But how are you moving them

#

The unit should have a rigidbody and a collider, and the building needs a collider too

#

If you are using rigidbodies, that is

#

Or is it just navmesh agent?

meager raptor
#

ye it's navmesh agent

#

sorry i didnt understand the question

sly wasp
# verbal dome What exactly does that mean?

I have different prefabs that instantiate the track object in any empty game object with a certain tag, I need it in a length because I know how long the prefab is, if I just instantiate it will do it on previous prefabs

#

I actually mean a length not a range

verbal dome
verbal dome
#

Oh track objects, so like pieces of road?

sly wasp
#

Let me describe it differently

verbal dome
#

Make a Vector3 before the foreach loop and add an offset to that vector every time you spawn one

sly wasp
# sly wasp How would I instantiate these objects in a certain range? I have public float r...

Ok letโ€™s think of it like this
I have different โ€œchunksโ€ that are spawned, they are prefabs that contain empty game objects with certain tags for different obstacles

So I was using the code at the bottom to instantiate them. It worked, only problem is that it generates in previous โ€œchunksโ€ too, so I need it to only generate them in a specific length

potent nymph
#

I'm trying to port the following HLSL code to C#

void Hash_Tchou_2_2_uint(uint2 v, out uint2 o)
{
    // ~8 alu (2 mul)
    v.y ^= 1103515245U;
    v.x += v.y;
    v.x *= v.y;
    v.x ^= v.x >> 5u;
    v.x *= 0x27d4eb2du;
    v.y ^= (v.x << 3u);
    o = v;
}
#

for this line v.x ^= v.x >> 5u;, I'm getting the following error:

#

I think Unity.Mathematics has a method for this but I don't know what this operator is

polar acorn
eternal needle
#

uint >> int

potent nymph
#

I'm wondering if there's a difference when converting that int to a uint

#

Ideally I'd like the code the behave the sameโ€”asking just in case

#

v.y ^= (v.x << 3u); also had that error

eternal needle
summer stump
#

!collab

eternal falconBOT
summer stump
#

Assuming you mean someone working with you

#

Then right here

#

Just ask

#

!code

eternal falconBOT
meager raptor
#

purpose: click on icon in the UI and should produce unit (ignore icons being same im too lazy to fetch 3 other icons)
problem: when i first select the building, the highlight doesn't appear, and each button produces the same unit (this is what it shouldn't do). when i deselect and reselect, the highlight appears and each button produces a different unit (this is what it should do).

my question is, why is the first part occuring?

polar wasp
#

just finished the junior programmer thing on unity learn ๐Ÿ˜„

potent nymph
eternal needle
polar wasp
meager raptor
polar wasp
#

and its only when you highlight the building first?

meager raptor
#

and everything works fine

meager raptor
#

there's no green circle when i select first

polar wasp
#

can i see some code?

opal vortex
#

Trying out events/listeners like is outlined here and hitting a confusing hurdle. https://gamedevbeginner.com/events-and-delegates-in-unity/
Basically hitting a UI button should trigger an event that the dice objects are listening for, and they then call their DiceRoll.RollDie public method. This all worked fine before using events, but for whatever reason the various public functions don't populate as options here. No idea why. Any suggestions?

Learn how to connect scripts & objects using delegates, actions & Unity Events in my in-depth beginner's guide.

meager raptor
opal vortex
#

Ex of what I'm expecting to see:

meager raptor
opal vortex
#

huh

#

ok it works when linking the gameobject to the script attachment, but how would that even work for like dynamically created objects during runtime

polar wasp
# meager raptor

the code looks airtight to me, if i had to guess, you would have to do some digging in your hierarchy to see if you have anything significantly different from your first building or something

meager raptor
#

it's like this

polar wasp
#

like the menu itself or how you would go about making the menu load certain scenes?

north kiln
polar wasp
young lava
#

I had a question. So I am making a top down 2D game. For my movement script, I am just setting the velocity, rather than using AddForce. I did some research and I found that it varies from game to game and what you want (whether you want a more realistic movement system or a more arcade snappy feel). I do want the latter, but when adding in features such as knockback should I maintain consistency and set the velocity for a duration or would it be fine to use both AddForce/velocity setting.

rocky canyon
polar wasp
rocky canyon
#

//set ur up forces from ur inputs..
//add or subtract any knockback or dash forces
//pass in the final result as ur velocity

polar wasp
meager raptor
rocky canyon
#

yea if they're different objects.. u start mixing them on teh same object is when u run into issues

polar wasp
# meager raptor

do you think its spawning the same unit because its just spawning whatever's first in the spawn order?

summer stump
meager raptor
#

got any ideas why the highlight doesnt appear first time round tho?

polar wasp
#

no clue honestly

rocky canyon
#

probably bc u set a bool and then read from it immediately

meager raptor
polar wasp
#

idk how your troop selection system works but the spawner you showed me just spawns the first troop in the array from what i saw

meager raptor
opal vortex
rocky canyon
#

b/c u call the Highlight function on interact

north kiln
eternal falconBOT
meager raptor
#

the building and player units both use that interactable script i showed u, when i select the units first time round they are selected just fine

north kiln
queen adder
#

why my ''on click'' appears like this??

north kiln
queen adder
#

thaaaankssss!

opal vortex
#

well it's ok now, thanks

young lava
summer stump
#

Since it's a networking issue, try in #archived-networking
Generally people get worried seeing someone in code BEGINNER asking about multiplayer

honest trench
#
    {
        if (other.gameObject.tag == "Checkpoint")
        {
            Debug.Log("Checkpoint");
            lastCheckpoint = other.transform.position;
        }
    }```
So this code should be debugging when the player (what this script is on) touches an object with the tag Checkpoint. I have checked that the tag is spelled right, and that the object with the tag has an ontrigger collider, but nothing. Any idea why?
teal viper
honest trench
#

When i put a debug above the if statement it also doesnt fire

teal viper
honest trench
#

the player does yeah

#

Does that mess with it?

teal viper
#

No. It's required for a collision.

#

Take a screenshot of both of the object's inspectors.

honest trench
#

Player:

#

Checkpoint:

teal viper
honest trench
#

Ah thank you

#

Works now

#

:)

potent nymph
#

for the following code I'm getting an error that a uint cannot be multiplied with a float

o = (r >> 8) * (1.0f / (float)(0x00ffffff));
#

if I cast the float to a uint, it gets rid of the error, but that messes up the output

teal viper
#

What are you even trying to do?

potent nymph
#

the original hlsl code looks like this:

o = (r >> 8) * (1.0 / float(0x00ffffff));
potent nymph
#

it's Unity's built-in voronoi shader code

teal viper
#

What does that particular line do? It might be simpler to rewrite it from the meaning rather than convert directly.

potent nymph
#

I don't know what it does to be honest

potent nymph
#

but I've successfully ported over several hlsl functions by simply fixing the syntax

tall delta
eternal falconBOT
summer stump
# native vortex

!ide
Seems unconfigured
At least the formatting is awful
Makes it really tough to parse

native vortex
potent nymph
summer stump
native vortex
#

script for player turn

teal viper
potent nymph
native vortex
#

@summer stump thank you!

proper moth
#

yo

#

im learning how to code so ima make a caculater

tall delta
#

!cs

this might be the place to be, unless there is a unity related question coming up

eternal falconBOT
proper moth
#

i know how to do ui

strong condor
#

A bit embarrassed but how can I simplify the below? I know I must not be doing this right

I had a lot of redundant code written below:

            {
                standing = true;

                movingNeutral = false;
                movingLeft = false;
                movingRight = false;
                movingDown = false;
                movingUp = false;

                movingDrag = false;

                standing = false;
                standingDrag = false;

                hoppingStraightUp = false;
                hoppingUpSide = false;            }

            if (standingDrag)
            {
                standingDrag = true;

                movingNeutral = false;
                movingLeft = false;
                movingRight = false;
                movingDown = false;
                movingUp = false;

                movingDrag = false;

                standing = false;

                hoppingStraightUp = false;
                hoppingUpSide = false;
            }
#

that I wanted to replace with using the function below:

        { 
           var current = currentMovementState;
           movingNeutral = false;
            movingLeft = false;
            movingRight = false;
            movingDown = false;
            movingUp = false;

            movingDrag = false;

            standing = false;
            standingDrag = false;

            hoppingStraightUp = false;
            hoppingUpSide = false;

            current = true;
            currentMovementState = current;
        }
         ``` 
So I can do this: 
        if (standing)
        {
            DisableAllMovementStatesExcept(standing);
        }

        if (standingDrag)
        {
            DisableAllMovementStatesExcept(standingDrag);

        }

        if (hoppingStraightUp)
        {
            DisableAllMovementStatesExcept(hoppingStraightUp);

        }
        
        if (hoppingUpSide)
        {
            DisableAllMovementStatesExcept(hoppingUpSide);

        }```
tall delta
#

a bitmask is the first thing that pops in to my mind. but that might be a bit confusing if your not familiar with bit logic

timber tide
#

you should break stuff into states more

#

rather, you're depending on flags more than the state that they are in

proper moth
#

just gotta make the script

tall delta
timber tide
# strong condor A bit embarrassed but how can I simplify the below? I know I must not be doing t...
if (standingDrag)
{
    standingDrag = true;

    movingNeutral = false;
    movingLeft = false;
    movingRight = false;
    movingDown = false;
    movingUp = false;

    movingDrag = false;

    standing = false;

    hoppingStraightUp = false;
    hoppingUpSide = false;
}

In this example, when you go into an idle state such there has been no input, you shouldn't care if you're moving in a direction nor need to read any input for it knowing that state.

#

And, for a moving state, instead of having 4 different direction flags, consider an enum for the direction

tall delta
# proper moth just gotta make the script

I'd recommend formulating the entire problem / question all at once. it's hard to parse what your asking if you don't do that, so your not going to get good answers.

proper moth
#

ok

#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;

public class Caculate : MonoBehaviour
{
public TextMeshProUGUI Result;
public TextMeshProUGUI Input1;
public TextMeshProUGUI Input2;
public TextMeshProUGUI DropDown;

// Start is called before the first frame update
void Start()
{
    
}

// Update is called once per frame
void Update()
{
    
}

}
when i try to add a input field in unity it wont let me

#

and a dropdown to

#

nvm

strong condor
strong condor
tall delta
# strong condor This makes a lot of sense. And sorry but I meant to ask why does my function to ...

well.. if you break down the function you posted. let's just remove the setting of all variables to false for readabiliy.
the logic you have is this:

    public void DisableAllMovementStatesExcept(bool currentMovementState) { 
          // set the local variable 'current' to be equal to currentMovementState)
          var current = currentMovementState;

           // ignore the last line and set it to 'true'
           current = true;

           //now set the local parameter 'currentMovementState' equal to true.
           currentMovementState = current;
    }```
so, I'm not sure what you wanted it to do, but rn, it's not really doing anything. except set all of these to false:

        movingNeutral = false;
        movingLeft = false;
        movingRight = false;
        movingDown = false;
        movingUp = false;
        movingDrag = false;
        standing = false;
        standingDrag = false;
        hoppingStraightUp = false;
        hoppingUpSide = false;```
native vortex
tall delta
#

and where you call DisableAllMovementStatesExcept(standingDrag); c# has no concept of the variable standingDrag like it does not understand that that's the same variable inside DisableAllMovementStatesExcept, since standingDrag is a value type, not a reference type. you're just telling it the current value (true or false) of standingDrag

https://medium.com/@dev.msalah/value-vs-reference-types-in-c-573e3cf6c5bf
this might clarify the issue.

summer stump
native vortex
tall delta
native vortex
#

@summer stump I've asked chatgpt for help and while it's helpful, I'm still lost on how to write "check for winner" script. I've watched some tutorials as well but still lost at where to start. Might ya have an area where I could start?

#

My tic tac toe game works and the restart button works (I got way too excited when the button worked) but I want the game to be able to keep score

fiery mulch
#

hey, having a small conceptual issue with physics. im using a basic rigidbody capsule 3d for my character with a capsule collider and some basic box colliders as platforms.

when moving along a flat platform, works perfect as intended. when moving along an inclining or declining platform, our speed collides against the object and creates some y velocity which then pops our character up. does rigidbody just do this naturally? and are there some settings i can use to turn this off?

strong condor
#

I think I will use an enum going forward for this instead of flags

#

thanks so much. it works as expected when actually passing around the reference

quartz mural
#

im tryin to set the status in my game

#

but it wont come up when i start the game

#
public class BattleHud : MonoBehaviour
{
    [SerializeField] TextMeshProUGUI nameText;
    [SerializeField] TextMeshProUGUI LevelText;
    [SerializeField] TextMeshProUGUI statusText;
    [SerializeField] HPBar hpBar;

    [SerializeField] Color psnColor;
    [SerializeField] Color brnColor;
    [SerializeField] Color slpColor;
    [SerializeField] Color parColor;


    Pokemon _pokemon;

    Dictionary<ConditionID, Color> statusColors;

    public void SetData(Pokemon pokemon)
    {

        _pokemon = pokemon;

        nameText.text = pokemon.Base.name;
        LevelText.text = "Lv " + pokemon.Level;
        hpBar.SetHP((float)pokemon.HP / pokemon.MaxHp);

        statusColors = new Dictionary<ConditionID, Color>()
        {
            {ConditionID.psn, psnColor},
            {ConditionID.brn, brnColor},
            {ConditionID.slp, slpColor},
            {ConditionID.par, parColor},

        };

        SetStatusText();
        _pokemon.OnStatusChanged += SetStatusText; //SetStatusText will be called when status is changed
    }

    void SetStatusText()
    {
        if (_pokemon.Status == null)
        {
            statusText.text = "";
        }
        else
        {
            statusText.text = _pokemon.Status.Id.ToString().ToUpper();
            statusText.color = statusColors[_pokemon.Status.Id];
        }
    }
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ConditionsDB : MonoBehaviour
{
    public static void Initialisation()
    {
        foreach (var kvp in Conditions) //kvp(key,value,player)
        {
            var conditionId = kvp.Key;
            var condition = kvp.Value;

            condition.Id = conditionId;

        }
    }
    public static Dictionary<ConditionID, Condition> Conditions { get; set; } = new Dictionary<ConditionID, Condition>()
    {
       // All condition's logic
public enum ConditionID
{
    none, psn, brn, slp, par
}
#

Anyone?

timber tide
#

where the debug log at

gaunt ice
#

where you call it?

bright zodiac
#

also, thats alot of bools you got there ๐Ÿ˜„

quartz mural
timber tide
#

but do you is the question

#

first instinct is to log stuff not working and just make sure it's being set and you've nothing setting it incorrectly.

#

because you want to first make sure it's not your logic that's wrong, but a problem with unity

quartz mural
#

what do the 3 dots mean again

timber tide
#

right click on it

#

usually a suggestion

quartz mural
#

nope

#

no suggestions

#

what does it mean?

#

some of the other functions haev it as well

timber tide
#

My guess is it's suggesting some naming convention, otherwise maybe the null-check operator is unnecessary

quartz mural
#

๐Ÿ‘

unique kestrel
#

is this the right place to ask for insight on a UI/scripting problem I'm stuck on?

#

and if not can someone direct me to the right channel?

#

I'm looking for someone who understands the UI elements better than I do (specifically the coordinates systems)

unique kestrel
#

right, but some servers will ban you for posting in the wrong channel

rich adder
#

without details can't even suggest channel

unique kestrel
#

Fair enough.

I have a GameObject that is in a GridLayoutGroup. I want to, when you hover over its container object, to create a duplicate of that object on a separate canvas(so that I can move it's position despite the GridLayoutGroup). I'm using Vector3.Lerp to move it's position every frame. The problem I have is that it's not actually moving.

#

this is on a script attached to the container obj

rich adder