#💻┃code-beginner
1 messages · Page 721 of 1
sounds.. unnecessary
So what would mine be returning? True and something else?
tuples are relatively new (and also just don't make sense for the try pattern)
because they will confuse the point
if you wanna be "technical" Tuple itself is still 1 type 😛
keeping simple for #💻┃code-beginner . tuples should be learned but later, also that^
most Try functions return a bool with an out
TryParse, TryGetValue etc
I need urgent help can anyone help me
if its urgent why not type the actual problem instead of extra unecessary question
Idk im panicing
unless you got a gun pointed at you, you're gonna be fine lol
i imported an old package intending to to import only the materials and textures
it imported all the scripts
and overwrote all the code
I'm assuming you didn't bother Version Control it beforehand ?
I havent done a git push in a while as i was very close to finishing
I did, i just havent pushed.
provided you have committed your previous changes you can just revert the latest changes to go back to the previous version
I havent
pushing is not required as that just pushes the changes to the remote
If you use any client app for Git you can also view visually what files have been added and remove/roll back selectively.
i have git extensions
the way to "undo" an import is to delete the imported file. there is no way, other than using version control, to roll back individual changes to files
it overwrote the files
so git should've tracked that?
I havent commited in ages idk
Also if you are using new version of the package you can just reimport that to clean up.
Then add selectively whatever you intended to add from old one
they should be still in the stashed files
Idk what you mean...I imported a package from my old code, a different project that has very similar script names. It overwrote the files of my new code
Then just this #💻┃code-beginner message
hey if i have logic in void update and it should call a method that usually should be called in fixed update, what would be the best way to do that? right now i have a bool that gets set to true when the function in fixed update gets called but i dont know if thats really optimal
like what? example?
just as an example of course if we take the code you wrote yesterday and we would try to move the character with rigidbody.velocity instead of transform position, we should usally call physics through fixedUpdateRight?
velocity can be set in the frame update just fine
it's stuff like addforce that has to be done in the physics tick
That's the way to do it
But yes, setting velocity in update is fine, it's adding forces that should be done in fixed
oh ok i thought everything physics based should be call from fixedUpdate
thank you it makes me really happy to have found the correct solution for once lol
https://hastebin.skyra.pw/zizilojude.csharp
Can someone tell me where I'm going wrong here? My goal is extremely simple. I just want to rotate an object to face another object, but only along a single axis (like a turret, in essence).
Here is a Gif demonstrating the code's behavior. It ALMOST works, but for god-knows-what-reason, certain positions result in the entire object flipping around.
I do not know how to fix this, nor do I know the "correct" way to do this.
It's because you're not providing the second parameter to https://docs.unity3d.com/ScriptReference/Transform.LookAt.html
So it's making its best guess
based on your gif you probably want the up vector to be along the red axis in the move gizmo
(or the opposite)
I am providing the second parameter.
Or rather that you're giving it the wrong axis for that
Probably one of those should be not negative
it's hard to say what's right without seeing the object's orientation
If you can select the rotating object with tool handle rotation set to "local" so we can see its axes, it would help
It's set to Desired Axis Zero, the first image is the object rotating, and the axis provided to Lookat is the second image's axis.
which object is Owner?
The second image. Here is a pic of the hierarchy, where TranslationGizmo is the Owner to "The Arrow" which is the one being tested
TranslationGizmo's transforms are never changed during any of these tests.
Ideally the yellow/up direction of this key thing would be pointing to the left 🤔
(or right)
in these images
Should I be using this same thing if I want an enemy colliding with the player to destroy the player, or is comparetag fine in that case?
yeah this layout of the red object is going to make things a bit complicated
you won't be able to just use one of the local directions of the Owner object here
enemy colliding with the layer to destroy the player
wdym here ? what layers
you're going to need to essentially take the forward direction and rotate it along the plane normal 90 degrees to get the up direciton required
Sorry, player
If the red object's Up direction was to the left in those screenshots (along the long axis so to speak) you could just be doing LookAt(_GlobalCamPos, Vector3.right)
So like this?
yeah exactly
I separated the graphic from the object itself
when gameobjects have scripts you should use those instead of tags.
Tags can be somewhat useful on objects without any scripts
TryGetComponent has limitation to check only current object you call it on, for finding components on parent/child
use GetComponentInParent / GetComponentInChild respectively
It wasn't QUITE that simple, since I needed to be able to rotate the owner object, but I do believe I have it working fully now, thank you very, VERY much.
I never would have figured this out in a million years.
(For context, the end goal here was to have my runtime translation gizmo's arrows always rotate to face the camera)
yeah you'd replace Vector3.right with whatever that direction would actually be so maybe parentObject.up or whatever it is 👍
Yup, that's how I got it working.
can you include functions in scriptable objects
yes
any documentation on it?
they are regular classes really ..
unity just interprets them as assets you can create from it
Not only can you include functions, but you can even add buttons to them. I use Easybuttons + SO functions to make editor tools a lot, because I'm too lazy to figure out how to make actual editor tools
the only difference from a regular class is they dont need to be created with new()
like monobehavior
THe problem is, I can't actually drag my enemy object into the player inspector because the inspector switches between them as I click 😂
Nevermind, figured it out, I can lock the inspector
lock the inspector tab. but also if you just immediately drag instead of clicking and waiting to drag it won't change the inspector window
Looks liek I actually can't do that anyway
why is 1 individual enemy on the player 🤔 ?
At least not the non-blue one that I can open in the heirarchy window
I guess because you can't put things from assets in things that are in the heirarchy window/
yeah because you can only put scene references in other objects in the scene, you cant put scene objects in prefabs
hey guys, is there a way to hide my comments or collapse them or something? I want them around to help me understand the code, but they take up so much space
other way around. you cannot drag references from the scene into assets, but scene objects can reference assets just fine
@thorn kiln still doesnt answer why do you even have a field on the player for an individual enemy 🤔
I dunno, it's what I did with the weakpoint thing we did
the weakpoint only knows about the objects in that hierarchy when its a prefab
so it only references its own parent
You would want to only grab enemy from player or vice versa at runtime
Eughhhh, I know how to make this work with comparetag. All this other stuff is so convoluted in comparison.
its literally the same process as tags though..
Which object are you trying to detect with compare tag
except you're not at the mercy of strings
Show the inspector of it
Im just trying to destroy the player when an enemy collsides with them
So show the inspector of the object that is the other in your OnTriggerEnter function
The object you want to detect collision with
if(other.TryGetComponent(out Player player)) Destroy(player.gameObject)
🤷♂️
Triggers and all , its the same exact thing lol
if(other.CompareTag("Player")) Destroy(other.gameObject)
Hmm, I was putting this stuff on the player controller
you crossed your wires somewhere no biggie
GetComponent / TryGetComponent when we usually want to detect something at runtime
SerializeField/Public when we are on the same hierarchy to what we want
Well my enemy script is current doing stuff like
private GameObject player;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
enemyRb = GetComponent<Rigidbody>();
player = GameObject.Find("Player");
}```
So I guess I gotta change that?
if only need to detect player on a collision you don't really need this
if you were needing to get a component / run a function on the player then you could put it to use. Although is not recommended using GameObject.Find. at very least you'd use FindObjectWithTag or Component
Well it's how I've been telling the enemy where to move towards
Everything on the Unity Pathways is basically wrong, is what I've discovered 😂
its not "wrong" to do so, they are good as quick results straightforward
but they are less efficient , something you shouldn't care as much as beginner so they don't go in the nitty gritty
Okay, let's back up.
Which two objects are involved in the collision? Which one is the one that has the code on it? What is the object you want to destroy?
Okay, and what two objects are involved in the collision
Player and Enemy
And which object do you want to destroy?
The player
Then this is it
It's very frustrating that anytime I do anything the answer is "unlearn everything you've been taught so far and do it differently"
Just use whatever script your player uses instead of Player
no its not unlearn .. the concepts are the same, you're just switching a few functions around
learning new ways to do similiar thing but better is part of the learning process
more important you question why you'd want to use one over the other, whys is important to understand before going further with a change
Well it feels like trying to learn breaststroke while still in the kiddy pool
does anyone know if there's anything I can do here or am I going to have to deal with it?
This code is literally just "Is the object I just hit the player? If so, kill it"
put them in regions maybe ?
that's not that complicated
how does that work?
#region
//Stuff inside here
#endregion
can you hide the region or, like, collapse it?
Yes that's what they're for
omg, this is amazing, thnx guys
how do i fix this?
Building /Users/mmasw/Downloads/ewewq.app/Contents/PlugIns/FirebaseCppStorage.bundle failed with output:
System.Exception: Cannot sign '/Users/mmasw/Downloads/ewewq.app/Contents/PlugIns/FirebaseCppStorage.bundle' because it is not a valid Mach-O binary.
at MacOSCodeSignDylibCopy.Run(CSharpActionContext ctx, SignFlags signFlags) in /Users/bokken/build/output/unity/unity/Platforms/OSX/MacStandalonePlayerBuildProgram/MacOSCodeSigning.cs:line 67
�u�
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun () (at /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPlayerWindow.cs:189)
cannot sign because it is not a valid Mach-O binary.
and what does that mean
you tried googling it
but how do i fix this
guessing it has to do with code signing something
is it because i orginally created on windows and then now tried to import it to macbook m1 chip
doubt it. I use the same project on 3 different OSs a day and no problems.
if you dont give any context there isn't much anyone can do with just that line of code other than "google it" like you could
what context could i give
if u want i can share u my project
in dms and u can try to run it
I don't need the project but you can just start by giving context like, I'm trying to build x for x, but this shows , I tried xyz, but giving me yze .. etc. stuff like that idk
im trying to compile my idle game and out of nowhere i get this error i havnt seen before
that i managed to compile not long ago and now i get this shit
chould i get that error because of this
what changed since ?
besides the missing project id, cuz im not on same account as pc on laptop and a few tweaks thats ab it
thats where the sign in issue is coming from? the missing project id
this seems more to do with Firebase than Unity cloud
and when i try to compile it i get 6 error all realted to firebase
What doesn't make sense about it
I dont know where to put anything
its possible its trying to tie something to xCode or something mac related but not linking properly.
try also backing up the project, removejust firebase or reinstall the sdk perhaps
When do you want this code to run
When the player and enemy touch
So, inside OnTriggerEnter or OnCollisionEnter
Because those functions run when an object collides
if im having an issue with like a window in the door opening with the door where would i got to ask for help about this? i was told something about dont cross post but cant remember what channel to go to i may just be dumb but idk
found a similiar issue
more likely not a code channel, if you're not sure use #💻┃unity-talk
So you should include screenshots/ video of issue and as much explanations
on the internet its a common mac issue

i will just didnt want to put all that in the wrong channel and im on windows
Okay, looks like I got it working, followed by a million errors because I just deleted the player and camera
I'm guessing I probably don't wanna destroy it
Just make it invisible and intangible and stop controls working
Or just make the camera not a child of the player, but that seems like it's gonna cause more work
depends what you want to do with the player after
sometimes you can just get away with simple null checks or some type of way to skip those things when the desired object isn't there
I'm figuring it out as I go
Most likely just simple gameplay stuff. Game over screen, press button to reset.
Thats for later though
yes those also require forethought, in reset , do we reset the scene or just certain objects. etc.
The pathway is making me do all this work on a personal project before I've even learnt half of the tools needed to pull it off
wdym "all this work on a personal project"
your first projects should just be test / learning projects not your "dream game" type project
At the end of the "Missions" it gives you a "Lab", which is it telling you what aspects of your "personal project" to work on
SO Im doing stuff like this
There is a way for anyone wondering, using ILSpy, thank g-d.
But it expects you to fill out a whole game design document before you've even learned how to do anything. I just skipped it because I thought that was stupid to ask me to design what a game will be before I even know what I'm gonna be capable of building.
its just practice for typical industry standard items for someone who might be getting into the industry
GDD is important to at least know about. You don't have to do everything there to a T.
I just think it's silly. It's like asking me to plan a circus performance before I've hired any performers.
I mean I do agree that it should probably be at the end or a sepearate course but still. If you think you won't need it now just skip it , no biggie
@rich adder You can extract the assembly.dll files and get the scripts that way
My problem for right now is that I want the character to bounce up after jumping on the weak point on top of the cubes (it's basically mario stomping goombas but with spheres and cubes), I tried using ForceMode.Impulse, but physics movement is... inconsistent, so I'm wondering how to do it.
still unclear what you're trying to decompile and why...
Before anyone says it, yes, I know it's not "inconsistent", it's the same force every time it's just competing with the force of gravity which is why it's different
most likely you need to reset vertical velocity before jump impulse
are you using velocity or addforce to move ?
AddForce Impulse
private void OnTriggerEnter(Collider other)
{
if (other.TryGetComponent(out EnemyHurt trigger))
{
Debug.Log("Collided with weak point");
Destroy(trigger.enemy.gameObject);
playerRb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
}
}```
just reset the Y velocity immediately before adding force that way it is always consisten
Right, right, just reset the Y axis velocity... hey, quick question...
var vel = rb.linearVelocity;
vel.y = 0;
rb.linearVelocity = vel;
playerRb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
should work
if the question is "how do i" then it's just "set it to 0"
Yeah, the next question after that would obviously be "how?", but looks like nav answered
it's also incredibly easy to google how to do something like that
You do get that google is just typing things into a box to get answers, and that this discord is also typing things into a box to get answers
you do get that wasting time bitching about everything here and not doing actual research is hindering your learning journey and you're just adding useless noise to the channel, right?
So for the past month i have been recreating a project that I already made, using cleaner code and efficient systems.
I tried to import a package from my previous project which was suppose to be only textures.
I didnt see at the time but it also had my old scripts folder.
When the import finished, it overwrote all scripts with the same name and added a bunch of scripts im not using anymore, I.e. I had ServerMinion, ServerGameManager etc. which where the same name for both old and new project. and unity overwrote the files completely.
But since unity doesnt allow build with errors, the oldest build still had my old code in it, so I was able to get that code, tweak it a little and put it back into the original scripts.
To the channel... code-beginner?
also #🌱┃start-here explicitly states that you should actually make an effort to google your questions yourself before posting here
Yeah but google doesn't waste a bunch of human time
So you had compiled a build but never made a git commit with those files? idk as long as it worked just seems strange lol
the oldest build still had my old code in it, so I was able to get that code, tweak it a little and put it back into the original scripts.
I meant you had made a build, then not committed the scripts but then replaced everything with new assets?
its whatever as long as it did what you wanted it to do, just thought it was strange.. You outta make commits before doing such changes. hopefully lesson learned ?
I only intended to add textures :e never thought something like this would happen
I've successfully made this, but now I need to figure out how to prevent the segments from intersecting. https://streamable.com/g1oqab
@rich adder i fixed the error
but now i can build the app
but it says this
can anyone help here?
something is broken in your Project / Editor 🤷♂️
no idea. have you tried refresh the library folder
like open and close unity project?
or what does that mean
You have to close project, delete Library folder and open it again.. Then you open old scene and try again
its a hail mary but worth a shot
i tried to re enter and now i get this
the fix was wat anyway
i will try ur hailmary
deleted my plugin folder
XDDDDD
just removed the fire storage all together
why did you even have it lol
enter safe mode and see where the compile errors are
or log in with account on my cloud
alr.
personally the Google SDK is always been dogshit.
you can always switch to unity auth and get the same login features
im cooked
im getting this The type or namespace name 'DG' could not be found (are you missing a using directive or an assembly reference?)
fix the top 3, and the last one might actually fix itself from the suggestion I made with library
for liekt he first 3
bet
ill try
or should i first
just delet library and open it again
fix the DG error first
might be related to you deleting the Plugin folder especially if you had something other than Firebase...
DG is DOTween
I mean, they probably have other assets too
but it's probably DOTween
What are you doing to try to move it
Im using set position
Show !code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
-# 🦗 🦗
how to fix these, bruhhhh
What's on that line
Look at the line the error says. What is that line doing
where does it say which line the error occurs?
In the error
Line 13, fifth character
so thats what live 13
now go check whats on line 13
What is line 13 doing
Congratulations, you fixed an error that prevented anything from compiling
i ran firebase from there but i recently deleted it
Now keep doing the same thing, start at the top, look at the line, and see what the problem is
alr thanks for the help
Start at the top and fix the issues from top to bottom
Do you need player.cs
That sounds like something that you are probably using
Why delete it?
Is this some demo or something you made?
its like a idle rpg i made
demo ish
Then hopefully you know what "Manager" is and why its missing
😂 okay good luck

free will go do as you want
be respectful though and dont break the rules of this server
I would highly recommend reading the errors to know what the problem is rather than just deleting random files
problem is
im an idiot that integrated firebase into the whole game and i now realized it somehow messed my whole game up and dont have a backup pre integration
then you would either update firebase to get it working OR remove firebase + places where you use firebase
so put the sdk back and see if compiles now that you refreshed those errors / library
😆 im gonna guess its a lost cause
And also probably all the other random files you deleted
Hopefully you didn't delete player.cs without a backup
i have backup
i went wild, but with a backup
wasnt it only DG namespace missing, how did we even get here..
They seem to be unwilling to take any corrective action beyond deleting files
very strange since they already did all this codebase...
all they had to do was put the plugin back or comment out the lines rq lol
Then you fix those
and by fixing them i get 33 more errors
and then i get 399 errors
and then i delete my game
If the compiler can't get past a file, it can't get to further ones
Also, how are you "fixing" them
deleting entire plugin folder vs you just had to temporarily test project build without firebase plugin
Are you actually solving the problem or just deleting the files that have errors
I don't know why but I can't help but think of this XKCD
Deleting a file gets rid of the errors but it doesn't actually fix anything
I've managed to get rid of the errors by adding if (player.gameObject != null) to the enemy script, though I'm not sure how to handle the camera being destroyed along with the player
You should probably not destroy your camera
That's a solid idea. It's a child of the player though. I might be able to fix that if I rewrite the code to make the camera follow the player instead, but that's just a maybe because of my skill level
cinemachine
follow , no code needed
So do I then make the main camera or the CinemachineCamera the child?
Well, for osme reason the CinemachineCamera just keeps moving further and further away on the z axis by itself even when the scene isn't playing... thats probably not intended 😂
you dont do that
neither
I think I'm doing okay. Not great, but you know, okay. This is definitely a form of gameplay.
that is indeed gameplay
id play
Yeah, it's on Stream Early Access, where it will stay indefinitely for the next 30 years, like pretty much everything else on Steam
Please pay me £60 for it now
Makes me sad when a game has the same price in pounds as it does in usd
I'm sorry you feel that way... please pay me £80 then
I've decided it's a quadruple A game now
I guess I should probably add a power up
This guy needs to be promoted to ceo immediately
I have an object that can be destroyed by two other objects, how would I differentiate them on the "OnDestroy" method so I can have 2 different things happen depending on what destroys it
Create two methods DestroyFoo DestroyBar and call one from one script and one from another call the code you want to execute then destroy the object
Putting this out again because I think my previous message got buried: I could still use help with this issue: https://discord.com/channels/489222168727519232/1407920726580793385
Is it possible to make objects from tiles? I want to give that blue platform a special behaviour with a script but creating an entire tilemap for each platform seems excessive. Is it the right way or is there a better way to do it?
Eugh, the thing that makes enemies destroy my player when they collide is on my enemy script, but I wanna add an if statement to not destroy it if powerup is true, but haspowerup is in my playercontroller script. Now I gotta remember how to access variables in other scripts
Guess I'll try asking chatgpt, I paid £20 for it after all
I think you can assign GameObject to tiles. And there is also a custom tiles feature which you can use to provide a custom behavior to tiles. You should look at the manual section corresponding to tile maps and tiles.
Nope, chatgpt is not being helpful, so that's a bust
Oh god, ChatGPT on game development? Are you trying to cause everything to crash and burn?
from the collison you have the players collider, so you can get GetComponent what you need from it
also ChatGPT is not going to be very helpful for most things and certainty not help you learn
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.TryGetComponent(out PlayerController player))
{
if (player.hasPowerup == true)
{
Destroy(gameObject);
} else {
Debug.Log("You are ded.");
Destroy(player.gameObject);
}
}
}```
Okay, thats what ended up working
No idea if it's good, all I know is it works
u should try to work out why it works more often and less bout ai
code makes perfect sense to me..
-> collision -> if has player -> if player has powerup destroy this -> if player doesnt have power up destroy player
just make it a regular gameobject , place it using the prefab brush if you want it to match the grid
AI didn't help with that, it wanted me to do lots of roundabout stuff that wasn't working
I just tried typing player in my enemy script to see if anything came up
how come the button clicks never execute PropertyClick() https://paste.mod.gg/nserauotlrll/0 thx in advance for any help
A tool for sharing your source code with the world!
hope you learned your lesson
it does not
Definately don't become an AI coder, you'll get nowhere fast
I wonder if Tea is still hiring
is the button visually hovering ? do you have an event system in the scene ?
the button activates in runtime I can give a screenshot
doesn't answer the question
btw thats funny I have a monopoly project I made a year ago..
oh nice
rn I'm trying to get it working and then I'm trying to add an ai
what was your project about
monopoly lol
what does visually hovering mean
do you see the button changing color when you put the mouse over it
it does when I click it
How do I use the prefab brush?
ok then most likely somewhere else in code you're not running the addListener / subscribe part
in the tile palette window you can switch which mode . You might need this package though
https://docs.unity3d.com/Packages/com.unity.2d.tilemap.extras@6.0/manual/GameObjectBrush.html
its often useful
oh please not this shit again
cant say for unity but in zig at least it does snippets well
I found it to cause massive damage vs slightly helping. It may fix one issue, but it'll cause you 500 other problems
keep it there if you want to discuss it, this place is gonna flood with that crap
if you blindly throw it at a codebase, yeah duh
but i digress
this is where I activate it if it helps
using System;
using UnityEngine;
public class Middleman : MonoBehaviour
{
public GamePlayerDataManager[] allManagers;
public Player triggerPlayer;
[SerializeField] private PropertiesPopupManager propertiesPopupManager;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
foreach(GamePlayerDataManager game in allManagers)
{
game.onPropertiesShown += ShowProperties;
}
}
private void ShowProperties(Player player)
{
propertiesPopupManager.gameObject.SetActive(true);
propertiesPopupManager.ShowProperties(player);
}
// Update is called once per frame
void Update()
{
}
}
Okay, tried looking online and couldn't figure it out. How do I change the material of an object when I pick up a powerup?
I only use it to remember syntax and sometimes paste in errors
you got to break up the problem
gameObject.GetComponent<MeshRenderer> = myMaterial if I remember correctly
like what is the material on, oh the renderer so go look at the docs for that
put logs in the chain of methods and see if they all run. including the loop that has the AddListener( ()=>
and find its material and sharedMaterial properties
Thank you!
Anyone know sane pakejka 5.2 coeffecients?
(bitmath snippets it does well too)
why would you just not write the bitmath out though, find it alot of it easier to repersent what i want in code then written language
doing it rn, but just to make sure did I use the lambda right on line 57? Does it have the same value for all for all of their clicks or does it work as intended
bc lambda stores the operation rather than the value
i mean this kind of bitmath
doing the capturing of the loop i is correct and should map to corresponding index.
@grand snow im the guy you helped earlier. can i ask you about a specific thing im having trouble with?
https://paste.mod.gg/upmxysdhghou/0 I updated it and the debug on line 58 never executes
A tool for sharing your source code with the world!
Debug.Log($"propertiesOwned: {player.propertiesOwned.Count}"); before the loop
oh wait I just realized its not supposed to run at first bc the player starts with no properties so the issue is probably around lines 68 to the end
so at the start player.propertiesOwned.Count is 0
what are the buttons supposed to do anyway ?
for now I just have them debug but later on I want to have them remove the property
so which one is not working right now thats supposed to work ?
private Material playerMaterial;
playerMaterial = GetComponent<Renderer>().material;
playerMaterial.color = Color.red;```Okay, these lines are working at least. But that's just colours. I need ot figure out how to change it to a material I have in assets.
this part never executes when the buttons are pressed private void PropertyClick(int spot, Player play) { Debug.Log("Clicked on property:"); Debug.Log(play.propertiesOwned[spot].Name); }
do the same as you did before to debug it, put logs and see where it goes wrong
I thought I'd jsut be able to do playerMaterial = gold;, but guess not
I think its MeshRenderer rather than Renderer
just make a field and assign it in the inspector, whats the big deal
Yo let me and u create a game
I already have a Debuglog in the method should I add it anywhere else
not in the method only lol thats pointless
you have to follow the flow of the code
How long you been using Unity?
ohh I see what you mean
you already established its not printing / reaching that part
work your way backwards
I'll start in AddProperty
either works since MeshRenderer extends from Renderer, mesh renderer just provides more stuff
ohhhhhhh ok
mb
Get lost, scammer/bot
player material is just a variable you made, you would assign it to the .material on the renderer
Well I did, that's what this is, right?
playerMaterial = GetComponent<Renderer>().material;
Changing that to MeshRenderer also doesn't work
what i am saying is you want to override the mateiral on the renderer, not on just a var you made locally
Ah, so GetComponent<MeshRenderer>().material = gold;
MeshRenderer renderer = GetComponent<MeshRenderer>();```
and then whenever you want to change it:
```cs
renderer.material = gold;
// or
renderer.sharedMaterial = gold;```
how does this look
public void AddProperty()
{
string inputText = amountInput.text;
bool isValid = true;
foreach(MonopolySpace owned in triggerPlayer.propertiesOwned)
{
if(owned.Name.Equals(inputText, StringComparison.OrdinalIgnoreCase))
{
Debug.Log("You already own this property!");
isValid = false;
break;
}
}
if (isValid)
{
foreach (MonopolySpace space in MonopolyBoard.Spaces)
{
if (space.Name.Equals(inputText, StringComparison.OrdinalIgnoreCase))
{
triggerPlayer.propertiesOwned.Add(space);
Debug.Log($"Player properties position: {triggerPlayer.propertiesOwned[triggerPlayer.propertiesOwned.Count - 1].Name}");
place++;
propertyTexts[place + 1].gameObject.SetActive(true);
propertyTexts[place + 1].GetComponentInChildren<TextMeshProUGUI>().text = $"{space.Name}, {space.Color}, Price: {space.Price}";
int indexCop = triggerPlayer.propertiesOwned.Count - 1; // Capture the current value of place
propertyTexts[place].onClick.AddListener(() => PropertyClick(indexCop, triggerPlayer));
//isValid = true;
Debug.Log($"Place: {place}");
//triggerPlayer.propertiesOwned.Add(space);
break;
}
}
}
}
}
It's telling me 'Component.renderer' is obsolete: 'Property renderer has been deprecated. Use GetComponent<Renderer>() instead. (UnityUpgradable)'
just use a differnet var name for it
unity used to have older accessors for communally used components
because you are using the renderer variable somewhere without declaring it
or you declared it in a different scope than you're trying to use it
so it's falling back to the defunct Component.renderer property
you are most likly missing the typename infront of it, i would recommend going through the basic learning stuff for C#
what am I looking at?
just test it lol
its what should get triggered when the buttons are pressec
you outta print out values like quantities before loops etc.. see if they match what you expect
Well it doesn't work in initilizers, doesn't work in Start(), and if it put it in OnTriggerEnter then IEnumerator PowerupCountdownRoutine() cant see it
you need to learn the basics
would need to make it a field to access it in multiple methods like that
Thanks, I'll try and learn the basics while I'm already trying to learn the basics.
I'm doing the beginner courses. I can't get more basic.
I'm trying to make a jump using natural gravity (9.81) just to make sure the formula I keep seeing around (Mathf.Sqrt(2 * 9.81 * h)) works. I have the height plugged in as 1 and am expecting the jump peak to be 1, but every time I run this code in FixedUpdate the highest value I get output is 0.956185. Is there a reason for that?
{
//For now just make sure the jump height is not only consistent, but peaks where I specified
//Well, the determinism is there. Now I just have to make sure the force is correct for the correct jump height
if (!Mathf.Approximately(transform.position.y, 0)) { print(transform.position.y); }
//Actually perform the jump
if (jumpQueued)
{
rb.linearVelocity += Vector3.up * Mathf.Sqrt(2 * -Physics.gravity.y * jumpHeight);
jumpQueued = false;
}
}```
you're learning Unitys Api , not the same as basic c#
Yeah, well the c# courses online suck
"Microsofts one is good"
No it's not.
@rich adder I got it working thank you for the help
how does it suck ? also gave you other options like w3schools which has basic info in a common format for other languages too
its a established langauge used for many things, there is so many sources for learning it
also they mentioned js which has simliar structures
honestly just do the code pathway and maybe follow a codemonkey tutorial
the second one is probably better
though either one of the two works
I did both
Has anyone had issues with this before?? https://discord.com/channels/489222168727519232/1410411052226580572
There, solved it
I'm on the pathway, it's the whole reason I'm doing this. But it expects you to make a game halfway through teaching you. Sure, changing materials is more of a unnecessary flourish I wanted to add, but other stuff it wants me to do, it hasn't really taught me yet, but is expecting me to be able to do halfway through the pathway
What part of the pathway are you referring to?
Can you link/screenshot it?
I mean where does it ask you to do something that they didn't teach you yet.
Well because the personal project is just something you make up yourself, I don't wanna just copy the other games they've had me work on already.
But in trying to make my own I've had to use stuff they haven't taught like
Cinemachine, linearVelocity, TryGetComponent
Maybe I didn't need to use those, but when I'm stuck on something and ask here, the response is always "the way you've been taught is bad, use this instead"
I don't see them implying anywhere in that tutorial that it's a "free to do anything" tutorial. They teach you specific things and expect you to follow the instructions. Obviously if you go beyond that(things that are probably taught later on), you're on your own.
If you still want to do that, you need to be ready to read the manual/api docs and look at extra tutorials.
Or just proceed with the learning path correctly. Once you finished all of it, you can experiment freely and work on your own project.
You're typically not expected to do your own thing while in training. At least not before the very end of it.
It's like you ask first year physics student to build a nuclear reactor.
You sound like an ad
You've got a sketchy name, have been in the server a week, DMd me to offer help instead of just offering in the server and instead of just telling me the name of the source you have, you're suggesting it teaches everything in the most vague way possible. If you don't understand how you sound like you're about to try and sell me a limited edition course, then you have zero self-awareness
I don't care what zombienet is. It doesn't stop everything about you coming off as sketchy
Yeah yeah, and I'm sure your dad works at xbox. It's not on me to trust strangers on the internet, it's on you to come off as trustworthy.
Just to note, but uncolicited personal messages are not welcome on this server. I think it's actually in the #📖┃code-of-conduct
Indeed. But the idea behind it is the same: don't bother people that might not want to PM. Keep it on server.
is there a way to have only 1 collider that is both a trigger and prevents clipping? my code runs twice because it has 2 different colliders
the point of a trigger is to be a volume you can pass through
what exactly are you trying to achieve? is a single non-trigger collider not sufficient?
No.
Restructure your code or your object to avoid that.
it's and object that needs to know if the player is nearby and once it hits a different collider it adds a score but since it gets both colliders it runs the add score code twice
my workaround was just making it add a 0.5 score so it rounds up anyways
yikes
I guess I'll just stick with that
Put the two colliders on different GameObjects. Colliders can go on child objects. You can then use layers to separate the collision interactions
How can I reference an Enum in my Scriptable Object?
I wasn't sure how to reference it, but this is what I've written. is this correct?
I don't know how to I just want an team with someone
I'm not
!collab
:loudspeaker: Collaborating and Job Posting
We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
• Collaboration & Jobs
This is driving me mad
In some projects when i open .cs files in /asstets/scripts IDE says something like "The active document is not part of the open workspace. Not all language features will be available."
Even though its RIGHT THERE and a file right next to it is opening just fine!
AI says to reopen the workspace (the workplace is correct) or to regenerate project files (which is not a thing i dont think)
anyone had that before?
!ide
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
make sure your ide is setup correctly as unity should be managing it for you so code files are "in project"
it was setup correctly 😭
but thanks to this i found out vs code package was outdated
so it works now
thank you 
private IEnumerator Trap()
{
// Disable movement
playerMovement.enabled = false;
botBotMovement.enabled = false;
// Fade to black
if (screenFader != null)
{
for (float t = 0; t < fadeDuration; t += Time.deltaTime)
{
float alpha = t / fadeDuration;
screenFader.color = new Color(0, 0, 0, alpha);
yield return null;
}
screenFader.color = new Color(0, 0, 0, 1f);
}
// Teleport
player.transform.position = destination;
botBot.transform.position = destination + botBotOffset;
// Fade back to transparent
if (screenFader != null)
{
for (float t = 0; t < fadeDuration; t += Time.deltaTime)
{
float alpha = 1f - t / fadeDuration;
screenFader.color = new Color(0, 0, 0, alpha);
yield return null;
}
screenFader.color = new Color(0, 0, 0, 0f);
}
// Re-enable movement
playerMovement.enabled = true;
botBotMovement.enabled = true;
// Play sound
if (audioSource != null)
{
audioSource.Play();
}
Destroy(gameObject);
Destroy(parentTile);
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject == player)
{
StartCoroutine(Trap());
}
}
}
So basically with this coroutine, my audio source doesn't play when I have it like this. If I move the Play Sound bit into the OnTrigger Enter, before the coroutine plays, I do get the audio but then the player doesn't move position like it's supposed to. Any idea why? Seems weird to me.
Assuming audioSource is on this object, you're destroying it right after starting to play it
Should I just add a yield return waitforseconds after the audio plays?
Do you want it to play only after those fades?
I added the wait, and even just doing that breaks the teleporting bit and doesnt move the player.
Ideally I want it to go in this order:
Hit collider > screen goes black > audio plays > player and NPC teleport > objects get destroyed > Screen fades back in. But I can't do that because destroying the object stops the coroutine and the screen stays black forever.
Leave the parts that destroy the object at the end
Yeah IK, but ideally I want the object to break (Destroying it) while the screen is black. Should I just instead make the object render fully transparent during the black screen to fake it?
You can disable/destroy the renderer
I'll go dabble ty/
{
public bool isOpen = false;
public float openAngle = 90f;
public float closeAngle = 0f;
public float smooth = 2f;
void Update()
{
Quaternion targetRotation = isOpen ? Quaternion.Euler(0, openAngle, 0) : Quaternion.Euler(0, closeAngle, 0);
transform.localRotation = Quaternion.Slerp(transform.localRotation, targetRotation, smooth * Time.deltaTime);
}
public void OpenCloseDoor()
{
isOpen = !isOpen;
}
} ```
i cant seem to get this door to sit proper the other set of doors ive done this exact same steps to works just fine but im at a loss of whats causing this. when i disable the script on this hinge the door sits fine right where it should be so im jsujst completely lose
You've changed the scale to -1 .. which might affect the positioning/rotation too - depending on what that does to the pivot.
What would be better, and easier to track, would be to set the scale back to 1,1,1. Create an empty parent, put the door script on that, put the door as a child and rotate it 180 on Y - Making sure the pivot of the parent is at the hinge side of the door.
Maybe it's already parented?, it's hard to tell with the cropped images
so i have them parented like this i knew missed showing something im sorry
which one has the scale of -1 ?
the left hinge
Change that back to scale 1 , as that is what's being manipulated by code
SpiderDoor lol
i swear im listening ;-;
no rotations -> 0,0,0
the rest of the children are 1,1,1 and now we are here
y 180 fixed it
now i just need it to do that when i hit play
2 things
- hopefully the pivot mode is set to center
- change the Children rotation, not the parent
your code is going to set the rotation to 0 or 90, so rotating the parent by 180 will only work until the door is interacted with
ideally, you'd want your code to be += / -= 90 .. so that the rotation of the parent doesn't need to be at 0
you helping with the orientation literally fixed it that y 180 was the last step holy shit you beautiful person ive been at this for 3 hours
you deserve free whataburger for life just saying
is anyone around to help a bit with an issue im running into uploading a vrchat world?
!vrchat
Join the growing VRChat community as you explore, play, and create the future of social VR! https://discord.com/invite/vrchat
Yo
quick question, if i have a player which has a script which has a function to damage the player, how would i call that script from another object, like a bullet or a laser
thx
also do you know why a random person dm me the second i asked the question?
Who was it?
@rustic laurel
!ban save 1194024921467191367 Continuing to spam DMs despite previous warnings.
buga_henry was banned.
oh sorry, no images?
It's fine, just ignore it.
ight
also, do you know how to do collisions (2d), ive got a circle collider on Player, and a box collider on Laser, and got this in the Laser code:
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.name == "Player")
{
Debug.Log("touchies");
}
}
you shouldn't use names for checking objects
anyways, you didn't actually say what the issue was
sory, when they touch, nothing happens
no log
nothin
then what do i use
hi, i need some advice,
in 2D for narrative game,
is it better to make an animation ours self with script
or
using animator of unity + clip
layers, ideally
tell me dem ways of layer collision
It depends on use case and complexity. You'll have to post actual example and ask in #🏃┃animation
ello?
i guess im making a bullet hell game without collision
did you perhaps think to search "unity layers"
then why does this channel exist
assign layers and then use layer masks to restrict what things can collider with/what physics queries hit
https://docs.unity3d.com/6000.2/Documentation/Manual/use-layers.html
we can give advice and help but i wont read you a bedtime story
sorry, for being new to game engines and using premade collision detection, my fault
To !ask questions when you have problems understanding them. Not to search elementary things for you.
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #🌱┃start-here
thats why we read the doc pages to learn how to use the engine and its features
We can also use the provided !learn ing content
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
is there something wrong with this code? I tried to run on my phone and it doesn't show the camera feed
in unity editor i can see the "obs logo" so i assume i placed the components correctly?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CameraFeed : MonoBehaviour
{
WebCamTexture camTex;
public RawImage img;
void Start()
{
camTex = new WebCamTexture();
img.texture = camTex;
camTex.Play();
}
public Texture2D Snapshot()
{
// capture current camera frame to a Texture2D
var tex = new Texture2D(camTex.width, camTex.height, TextureFormat.RGB24, false);
var pixels = camTex.GetPixels();
tex.SetPixels(pixels);
tex.Apply();
return tex;
}
}
Could be permissions are required to access the camera
unity offers things to check + request permissions
they also need to be added to your AndroidManifest
how do i do that? it wouldn't let me to edit the xml file
you opened it in a browser instead of an editor
you can edit files in..editors
would just use your ide or code editor
oh
You edit it in your project before building https://docs.unity3d.com/6000.2/Documentation/Manual/android-manifest.html
You are looking at the build output, do not do this
oh thanks! it's working now
is there a easy way to set up a pop up to ask for permission?
I have to get the permission manually by opening setting > app on my phone :/
o/s level permission popups usually appear automagically - try installing the app fresh
We don't allow modding here.
Huh? But that is unity server though
Yes, and on this Unity server, we don't allow discussions on modding, pirating or asset ripping. You'll have to find another community.
The hell?... How do you put modding in the same line as other two things?? I am modding a licensed game that I bought!
That is weird. Farewell
They all break tos
doesn't seem working, i might have to make a script to ask for it :/
See ya
This is an official unity server so we can’t talk about em
most people here don’t actually dislike modding it’s just not the right place
A lot of people got into game dev learning through modding. It's just this server is dedicated to learning Unity and modding always about overcoming limitations of some existing application build (which is out of scope of this community), while also in most cases is against game's TOS.
how i can make this effect on unity?
billboard without depth test with fixed size
don't crosspost
this is a code channel ... delete and ask in #📲┃ui-ux (unless you're asking for code how to?)
i need code to make fixed scale
my english is bad
im portuguese
srry
you'll want to get the distance from the camera, and increase/ decrease the scale
in godot it's so easy, but I can't enjoy using godot. I think I've gotten used to unity
You'll also probably want to do transformOfTheText.LookAt(cameraTransform);
Does anyone know wtf is lagging out my project so hard? I only rly have 2 files that handle movement and spell stuff respectively so it really shouldn't be running like this
player movement code --> https://paste.mod.gg/ydjtgosrlrna/0
player spell code --> https://paste.mod.gg/cvtxqbwpbups/0
use the profiler and check
how do I do that?
Handling Physics based movement in Update() is the issue 🙂
try that and hope that helps 🙂
where else would I put that though?
that isn't in itself an issue
linearVelocity can be set in update just fine
this is an issue though
airTime += Time.fixedDeltaTime;
the AddForce as well
The values in my PlayerWeaponScript are not changing to the values in my SO. Am I doing this correctly?
The Method is definetely being called since the Debug.Log is working
why is this an issue?
because it's in Update
well where else would I put it?
FixedUpdate
Why not just keep a ref to the scriptable object...
using fixeddeltatime does not automatically make it part of the fixed time step
What do you mean?
FixedUpdate() is suited best for physics based interactions 🙂
If you want to access information about the "currently held weapon" you could just keep a reference to the scriptable object for that gun instead of copying all its fields
would be easier wouldnt it? (presuming you do not try to modify it)
well what's the difference between Update() and FixedUpdate()?
Update is every frame, FixedUpdate is each physics update
thats why the docs and any good tutorial does physics stuff in FixedUpdate() !
a quick google answers the question
I'm still not 100% sure what you mean. My PlayerWeapon script is on the player, not the gun, and I'm copying the fields that I want to change when a different gun is selected/picked up
You should also consider having your weapon pick up functionality work by having references to the varing SO's so you can have the player pick up many weapon types without abusing tags.
Hey! I've been trying to replicate a grid system video from youtube, and so far everything works except for the onmouseenter highlight of a tile. It seems that the only thing I would need for this is a collider 2d for the tile prefab, yet somehow I don't get anything
I'm not sure if I'm doing something wrong in my code since it's pretty basic just a Debug.Log in the OnMouseEnter method
show the code otherwise we don't know
are you using the new input system or the old one
Well trust me when I say that its a much better idea to update a reference to the weapon data instead of what you are doing currently.
most likely defaulted to new input system
all new projects use the new system now
how do you check that?
switch to the IPointerEnter interface and use the Physics2D Raycaster
So, right now I'm changing the data within the WeaponScript. How could I update a reference to the weapon data?
I have this so maybe the new?
does onmouseenter not work in 2d or?
it does but you need to switch input system to Old
You can switch it to Both inputs or Old in the Player Settings of Project Settings
you can have that and still be set to old/ both.
Project Settings -> Player -> Other settings somewhere .. last option of the 'configuration' section
Example to illustate logic:
private WeaponData currentWeaponData;
private void OnTriggerEnter(Collider other)
{
if(collider.gameObject.TryGetComponent(out Weapon weapon)
{
currentWeaponData = weapon.data;
Debug.Log($"Changed weapon to {weapon.data.name}");
}
}
we work with a reference to a scriptable object that holds the weapon data/information instead.
They are talking about an alternate system that uses an EventSystem, physics raycaster and alternate events. This works regardless of input system and is better over all
many events exist check doc page above ^
How is this different to what I've done?
Instead of copying over loads of data manually we just dont... What if you had 50 fields to copy? How is that sustainable?? Its not.
I know I shouldn't be concerned about performance this early, so what are the things that make it better?
Its the same system that UGUI uses to perform its events so the UI will obscure input which is often what we want
And as I said it works regardless of input system
It works if your player uses a controller to move a pointer, unlike OnMouseEnter which is stuck to mouse
Okay got you, but how can I write it so that I can apply all the SO data at once?
You dont and you have some critical miss understanding if you think you need to do this
they're saying you just use the SO stats directly when you shoot or whatever else
Alright yeah it does sound better that i can use both systems and make it work for any pointer
no you only use the Ipointer events and event system way
IPointer works for any device that you can set to move the pointer, including mouse ofc so you only need that 1 system
yeah I'm going to use the ipointer thing, not the onmouseenter
oh good
It requires an event system in a loaded scene to work
as well as a physics raycaster OR physics 2d raycaster to work with the colliders you want
2 things to keep in mind with this
For physics colliders you need to add the Physics raycster on the camera
UI elements CAN block the casts so if you have UI over your collider, it will priority the UI unless you play with a ScreenSpace - Camera's Plane distance
Does the event system come whenever I use the Interface or do I have to add it myself?
can't I just use layer masks (if that's even an option)
when you add a UI element typically Unity will add one to the scene
they're all going through the same raycaster already that has its own filtered layers
the "Ignore Raycast" layer you see
Yup found it in UI > Event sytem too!
damn so I have to use Camera's plane distance to make it work with UI
I don't wanna mess it up
Seems like your PlayerWeapon script should reference an SO and instead of calling a function on this completely different script you just change which SO the PlayerWeapon has
no I'm saying it works regardless you just have to keep in mind which one will be "infront"
if your UI item is non-interctive (like healthbars, scores etc.) and you don't want it to block the ray to Collider then you can untick the Raycast Target option
ooh okay I get that, sometimes I'll want UI to be interactive, sometimes not
is that option in the collider component?
So like do I just put all my movement and physics stuff in FixedUpdate() or smth
no thats only for UI elements, like Image, Textmeshpro etc.
so for objects I have to disable the collider if I don't want it to interact, and UI disable the option?
using the physics raycaster, if you don't want the IPointer to fire on the script then you disable the collider sure, but maybe you might be misunderstanding it.. probably 90% of the time you shouldnt worry, just putting the little caveat of this system out there
Imagine a giant Panel / Healthbar covers your object with the collider, your IPointer will not fire on collider object if its behind UI
yeah I got that so far
I meant that if I don't want an object specifically to be interactive at runtime, all I gotta do is disable the collider
in terms of PhysicsRaycaster only
but other interactions too sure, OnColliderHit , or physics
okay okay I'm starting to get it a little
my only 'concern' is that I might be a bit lost on how to make it work, as I do I have to check all the time where the pointer is, or can my objects just react like with onMouseOver
it works exactly like OnMouseOver. The event such as
https://docs.unity3d.com/Packages/com.unity.ugui@1.0/api/UnityEngine.EventSystems.IPointerEnterHandler.html
will fire when your pointer enters a collider / a ui element
(The script has to be on that element though)
for colliders a Physics Raycaster is needed on the camera
this page is a different event (clicking)
but shows how to use these interfaces in code
https://docs.unity3d.com/Packages/com.unity.ugui@1.0/api/UnityEngine.EventSystems.IPointerClickHandler.html
I just added that to the camera
ooh alright thanks for the doc!
there are two, one for 2D colliders and one for 3D
I added the 2d one
https://hastebin.skyra.pw/wexemuwupu.csharp hey im trying to give my line collision using an edgeCollider2D, but i get a NullReferenceException on line 34 ann i dont know why. could someone help me? thanks in advance
points2D is never initialized
therefore its null
Unity auto-initializes an array only if its serialized in the inspector, hence why points works without errors
oh
ok i fixed that, but now i get an ArgumentOutOfRangeException
how would i fix that?
well you don't have enough elements and you're going out of bounds
what do you mean exactly?
oh wait..
which line is throwing that
idk it changed a bit wait
heres an examplecs var list = new List<int> { 10, 20, 30 }; list.RemoveAt(5); // Index 5 does not exist throws that error
i is outside the range of Points2D
points2D and points quantities dont match
what should i do about that?
Don't try to acces an index that is bigger than the size of the list
points2D is literally empty
you initialized it, great.. now your points2D count is literally 0
A list is a collection of things. You can add stuff to it. But you can't say "Get me the fifth thing in this list" if the list only has two things in it
ohhhh like this? points2D.Add(new Vector2(points[i].position.x, points[i].position.y));
in a for loop ofc
That would add an item to the list which would get rid of this issue, but you're doing it in update
That list is going to get very long very fast
so i add them in start and replace them afterwards in update?
what is even the point of points2D if you already have points
ohh I see SetPoints wants a list of Vectors..
points is an transform array which is required for the LineRenderer and edgeCollider2d needs a list of vector2
yes
i dont really get why they wouldnt just use arrays tho
List<Vector2> points2D = new(points.Length)
this might be pretty heafty too though..creating a new array every frame is ugly
cant you just do it in SetupLine ?
need more context to make a suggestion, like why is this looping in Update
https://hastebin.skyra.pw/yiyukitumo.csharp this is what i tried now. errors are gone but it falls threw the floor now
Hey, just have a quick question. We're trying to add local multiplayer and need seperate UI's for each player. We've found out that theres a MultiplayerEventSystem and are trying to use it, but although the setup seems correct it doesn't want to recognize UI when hovering over e.g. buttons. Our current setup consists of a player input whose actions both have a gameplay and ui component, aswell as the eventsystem as the UI input module. The event system itself has the same action map, aswell as the player root being the canvas of our player UI. I know this isn't much information, but I don't want to spam the channel so please tell me what kind of information you need ^^ - thanks!
it would probably not be bad to say, I do generate the UI using code whenever I need it, so since that might be relevant I thought ill post it here instead of unity talk. All it does is replicate prefabs and places it under the canvas though
hey, i have a softbody system with a lot of spring joints. to make it a little easier to adjust the values i wanted to make a script to handle those. is there a way to differentiate between those springs if there are multiple on the same gameObject?
No.
Depending on what you want the script to actually do, you'd need to have a field for each spring joint, and then assign each spring component. You'd then know which is which
ok thank you. i think ill stick to getComponents and throwing them all in the same array then
Hi, i tried to make (now a normal) movable plataform, tho it makes the player slip to the direction is moving, i mean, if the plataform goes right, the player gets yeeted right. It makes sense but i still dont know how to "calm it"
{
RaycastHit2D hit = Physics2D.CircleCast(transform.position, groundcolliderradius, Vector2.down, groundcolliderdistance, groundlayer);
if (hit.collider != null)
{
// Check for WalkingBox component on the object we hit
walkingBox walkingBox = hit.collider.GetComponent<walkingBox>();
if (walkingBox != null)
{
Rigidbody2D boxRb = walkingBox.GetComponent<Rigidbody2D>();
if (boxRb != null)
{
rb2D.linearVelocity += new Vector2(boxRb.linearVelocity.x, 0); // Only add horizontal velocity
}
}
return true;
}
return false;
}```
When do you call this function and how often do you call it
everytime it touches the floor
Whenever it starts touching or as long as it is touching
i guess as long
Because every time this runs you add velocity
If you're running this every frame you're going to add the velocity every frame
I’m making a fighter game like stick fight but making sliding work is annoying.
The player never slides because of the move force how do I fix this?
bur wait, then how i can make it stand on top?
the way to make it was to make the player detect if there's a "movableplataform" below and plus it own velocity with that one
That's how.
You would set the velocity to that. Not add it
You would include that
wat
You would set the player's velocity to their movement plus the platform's velocity
oh, ok
i need some advice on how to structure my items with my inventory, to simplify alot, currently the inventory is a script containing a field which is a list of IDs that (and helper methods and such), through ItemDatabase static method (a class that holds all the ItemData scriptable objects) you can get the full itemData through the ID, and i have a "Use" method that gets the index slot, find what id is stored in that slot but then.. thats where i got stuck, currently, that is all that the items are, an SO with these general fields every item would need, however i want each item to have its own ability, so each item would have to execute a unique method related to it, where we give the gameobject player as a parameter and from it, it can get any references it needs meaning this method can be static, no reference to an actual item in game is needed. but i dont know whats the best way to build a database with such methods and how to get the right method with the id.
i mean i could have children of the SO where each item has its own SO that inherits from the main ItemData SO and then inside it i can have a function or something but ill neeed like 100+ files each with its own SO unique child and that just seems impossible to track and chaotic.
i cant really think of an effective way to build an efficient system using what i have as the foundation
Will items ever have their own instance data? Like once an item is in the world, will it ever differ from another of the same type? (i.e. it has its own HP or uses to track)
how? i dont get it, i thought i did it right now
Let's say your velocity is 1, and the platform's velocity is 1.
This code runs, what is the player's new velocity?
but wasn't this how should be done?
also, player's velocity in theory would be 0
im AFK
yes, the inventory is actually 2 dimentional, made that way so each item stored can have unique data, that way i can stack items that are of the same type but have different use amounts left, kind of like beign able to stack tools in minecraft. This also means when an item is "dropped", its specifics are passed onto the gameobejct version of the item.
this will be easier to explain with visuals, so in plain terms the inventory is a list of these structs, and ItemPickup has a "uses" field that is set to the amoutn of uses the items struct has when dropped, and likewise when we pick up the item, we set the new structs use amount to the itemData amount, so they do sort of hold specific data
Okay, so let's go with that hypothetical. Player's velocity is 0, and the platform is a constant velocity of 1.
First time this is called, what is the player's resulting velocity?
You would do the things you'd normally do to set the player's velocity for your input, but then also add in the platform's velocity
It would be simpler if the Item instance class remained consistent from inventory to world gameobject. Only difference with the latter is that the gameobject refers to the Item it physically represents in the world. So Item contains instance data, and refers to an ItemData with all of its other information. ItemData also has a reference to the Ability you want it to possess. The Ability can also be a scriptable object type, with an abstract method for executing, and you just derive a new form of it for each ability you need.
i add force for the imput
Then you're probably just going to have to detect when you enter and when you exit the platform and change the velocity then, or else you're going to need to figure out how much force the platform imparts on the player to give it the same velocity and add that as well
o h, ok
can someone help me creating a plane mesh from a few verts basicly acting as an outline? never did this before and i need it to fill in my softbody with color
you can easily construct a new mesh object with some verts and triangle indicies
https://docs.unity3d.com/ScriptReference/Mesh.html
what do you have rn?
i dont have much that could be useful. just an array of transforms that could be used to construct the plane. but i also dont have points inbetween like a grid
for a quad you just need 2 triangles
but you could just use the unity quad and scale/rotate/translate it as needed then
but will it fit the shape of the softbody? either if it has an odd shape or if its getting squished?
a plane wont cut it. use a inverse hull shader to do an outline of a mesh
or some post processing effect
yo what the hell is an inverse hull shader
Small help
what is the correct way to do this line of code
follow.TrackerSettings.BindingMode = follow.TrackerSettings.BindingMode.WorldSpace;
for cinemachine?
Could someone help with an issue with InputField in a layout group?
This issue it is pushing me to take another break due to days of frustration and different changes yet no results.
transposer.m_BindingMode = CinemachineTransposer.BindingMode.WorldSpace;
i believe
Context would help
you need to grab the CinemachineTransposer and setting the binding mode enum
yea more context would be helpful.. and also what ver of cinemachine u using?
inverted hull shader is whats commonly called
An inverted hull shader is a computer graphics technique that creates a visible outline around a 3D object by drawing the object twice.
ok thank you
Is a technique to do outlines cheaply. This explains it a bit: http://www.ronja-tutorials.com/post/020-hull-outline/
it draws the shape a bit bigger than the object originally..
and then thats placed behind w/ a black fill for example
thats really cool ill remember this if i try to make outlines in another project but rn i kinda need the opposite lol
I am using Unity6 so CinemachineTransposer is obsolete now and it uses CinemachineFollow
On awake i am trying to set the bindingmode to worldspace for a safety measure
private CinemachineCamera vcam;
private CinemachinePositionComposer composer;
private CinemachineFollow follow;
void Awake()
{
vcam = GetComponent<CinemachineCamera>();
if (!mainCamera) mainCamera = Camera.main;
composer = vcam.GetComponent<CinemachinePositionComposer>();
follow = vcam.GetComponent<CinemachineFollow>();
if (follow)
{
var settings = follow.TrackerSettings;
settings.BindingMode = follow.TrackerSettings.BindingMode.WorldSpace;
// ! Member 'BindingMode.WorldSpace' cannot be accessed with an instance reference; qualify it with a type name instead
follow.TrackerSettings = settings;
}
}
explain "opposite"
can you draw a shit picture or find a reference for what you want? your original description about making a plane is too vague
as i said, we can place a square/rectangle easily so we dont have a good reason to "make" a plane procedurally
settings.BindingMode = CinemachineFollow.TrackerSettings.BindingMode.WorldSpace; ``` i feel like u should copy out the settings
and then ~~assign ~~ modify them and reapply
follow.TrackerSettings = settings;
but im going off dusty knowledge.. and cinemachine did that big update and now im still discombogulated
Thats why im confused, damn API changes 
ya, i believe it kinda works like how u'd change a material..
you'd instead copy that material, (change the copy) and apply it back to the renderer
i just know im always using vars when messing with cinemachine 🎥 😅
in this case a struct
these points are connected and make up my softbody (i disabled the outline for it to be more obvious). my goal is to get a texture inbetweeen that or atleast fill it with a solid color. thats not that easy though as its a few dots hewld together by hopes and dark magic
TrackerSettings being a value-type and not a reference
ohhh.. would u draw the shape using the points u already have?
each one being a vertex.. and then connect them with triangles
thats exactly what i try to achive
ohh coolio.. its pretty straight forward.. unfortunately im not one of the ones that would know how to do it 🤣
but im... lets say not really experienced
if the vert count can change you may need to trianglulate and gen uvs to then make a mesh
otherwise it could just be pre made
if you just need an axis alined box behind the bounds that is easier

@rocky canyon
Just in case wanted updates - i figured it out
its so weird!
had to add using Unity.Cinemachine.TargetTracking;
and then this just worked...
settings.BindingMode = BindingMode.WorldSpace;

Cinemachine is doodoo cheeks
awesome.. more straight forward than i thought
gotta go treasure hunting thru namespaces for any kind of functionallity in the new cinemachine system 😄
wow namespaces anyways
always.. even the old cinemachine was a lot of namespace fiddling
sadly the shape changes
reminds me of doing any kind of post processing

Was going to mention that it's a part of the target tracking namespace but thought you guys had solved the issue.
https://docs.unity3d.com/Packages/com.unity.cinemachine@3.0/api/Unity.Cinemachine.TargetTracking.BindingMode.html
BindingMode got moved out as a top-level enum inside the TargetTracking namespace.
Old muscle memory (CinemachineTransposer) expected it to live under the component type itself.
Unity6 modularized Cinemachine to reduce cross-dependency
-# ai explaination
keepin the docs close-by helps
theres certain docs more important than others..
for me its cinemachine and DoTween
Yea then you may need to dynamically produce triangles from the verts.
I think this lib can help with doing this: https://github.com/gradientspace/geometry3Sharp
ohh looks extensive
i think ill search for a yt tutorial or something really want to understand what im coding as i mostly doing it for learning urposes but thank you very much
going from an ngon to triangulated mesh is not simple but if you can find a good algoritm to impement it may be worth it but there is a reason why libraries exist
i think ill go for a plain color. ngons shouldnt be a big problem right? right?
gpus can only draw triangles so you MUST solve the problem
aw man😔
software like blender has automatic ways to triangulate an ngon for us
ikk why cant unity be blender...
3d software is not the same as a game engine
https://en.wikipedia.org/wiki/Delaunay_triangulation
techniques do exist but yea its a tricky issue dealing with dynamically made shapes like this
Hmm actually I wonder if probuilders poly shape could be used for this
posssibly
I just did some searching and they use a lib poly2tri in probuilder 🤔
this could be used hopefully to just do everything for you @hallow acorn ⬆️
what exactly is that?🤔
hold up.. clarify something to me.. is this meant to be a solution to build the shape at runtime or before?
can probuilder be utilized @ runtime? just curious
I think so, anyway probuilder uses this c# port of poly2tri
https://github.com/MaulingMonkey/poly2tri-cs
Incase you dont know, probuilder lets you make shape models easily in editor and these should hopefully be modifyable at runtime too
https://docs.unity3d.com/Packages/com.unity.probuilder@6.0/manual/index.html
saw this before yes
but im completely overwhlmed by what im seeing
how tf do i use that
why is it so complicated to color in points held together by hopes and dreams
just not a common thing thats done all that often ¯_(ツ)_/¯
Its just how it is, procedural geometry is not an easy thing to do
Try making a pro builder poly shape in editor and see if it makes a shape as you expect
therefor theres no drag and drop simple solution that exists just yet
you could be the first! 😉
dont even know how to install the package or what it is😭
well thats easy. go to the unity package manager, unity registry and search
cant find it? google time
All feedback is welcome!
My website: https://rumpledcode.com
Company website: https://double-lens.com
Download the scene:
https://drive.google.com/file/d/1q6_3DFFwctqXGX0gl3u9L0Un3GX2HIqU
Useful links:
https://docs.unity3d.com/Packages/com.unity.probuilder@4.0/manual/api.html
https://docs.unity3d.com/Packages/com.unity.probuilder@4.0/api/Uni...
im 15 and in my second year of programming class in school starts on monday bro😭
headstart 💨
well try to use the information we have given you to achieve this if you want
rn im having endstage imposter sydrome haha but i wont give this project up! atleast not if i dont get the damn color working
^ it'll be a combination of
- installing the package
- looking at examples
- reading the docs
- googling what ur attempted + probuilder
- find threads and convo's / maybe tutorials doing what u want to achieve
or if its not 💯 do what u can w/ what u know then try to fill in the missing pieces... its all about experimentation, trial and error, and iteration
find other softbody resources (similar to urs already)
see how they make the shapes-> fill in the vertices
cmon bro...
You need to install git https://git-scm.com/downloads
or just install and import manually
what is git?
wait hangon a sec what are you doing
i only know github
install pro builder
i have
probuilder is avail via the asset store / package manager
and was this error a result of that installation?
i think they went for this too #💻┃code-beginner message 👇
no it was when i tried installing the other thing afterwards
ah no no that was me sharing the lib they use as reference
so dont do that and you are good 😆
so what is git now?
dont worry you tried something incorrectly so dont bother
what should i do instead then?
its inside a monobehavior class too
play with pro builder in editor to see how it works https://docs.unity3d.com/Packages/com.unity.probuilder@6.0/manual/polyshape.html
https://catlikecoding.com/unity/tutorials/procedural-meshes/creating-a-mesh/ heres a good resource for the whole
"creating a mesh" topic
lets crawl before they run to the moon
They dont know what git is so probably too much for em rn 😆
THEN TELL ME WHAT GIT IS MAN
ya, just as a resource tho to kinda double back to and compare.. the more the merrier ya know
has some basic concepts which are still prettty relevant
version control software, its what all repositories on github use.
oh okay
Catlikecoding always working😂
i have github installed
why did the mp4 import like that.
More context would help
like what
Virus ☠️
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
github desktop is a GUI client for git so you know.
its very important to know that github is just a online host for GIT repositories.
very funny, ive imported video before though, dont know why that one is weird, will try again
u can use www.streamable.com for a temporary link if it doesnt work
im basicly a full time dev
A tool for sharing your source code with the world!
You need to finish the statement on line 60
Alright, trying again, character is only moving towards "true north" and not changing direction based on which way they are "facing" ontop of just not turning
turns out i didnt press the finish recording button lmao
u need to run it thru a function to make it direction relevant / local to the player/cam
lmao thanks tho
~~```cs
// grab our input
float h = Input.GetAxisRaw("Horizontal");
float v = Input.GetAxisRaw("Vertical");
Vector3 localInput = new Vector3(h, 0f, v).normalized;
inputDirection = transform.TransformDirection(localInput);```~~
~~something like the TransformDirection method here ~~(edit: incorrect, i seen later that he's multiplying w/ the local transforms x and z)
thanks for the documentation, will read up
]
@grand snow i dragged the folder in my project and got 54 errors i cant do this anymore
what folder what are you doing???
idk man😭
should i make smth similar to this in the void update or give itself its own function
u already have ur movement vector and stuff working?
this one
plz ignore this forget it exists RN delete it from your project
i have after i got 54 errors
what im i supposed to do now tho
