#💻┃code-beginner
1 messages · Page 310 of 1
I was referring to them not being able to use the TMP_Text in the dictionary's field initialisation, how they wanted to do, as they can neither reference the TMP_Text field created above, nor create the new ones, as it's abstract
This is not IEnumerator
Then won’t the bullet go faster and slower based on computer power?
no
velocity is velocity
velocity is m/s
Ok
that's what's happening right NOW because you put that there
if you multiple it with s, it becomes m
How do I change the hit box on the vehicle so the ramp isn't on the front
So if i am calling start routine insdide that function. how do i stop the code under it from starting till its returns
The Collider determines the shape
Thanks, it works
You can't use yield unless this function is also a coroutine
and you can't pause execution in this function unles this function is a coroutine
that's the superpower of coroutines
so the answer is - you don't unless you make this function also a coroutine.
Thanks
So best answer id to remove every thing under into the coroutine?
idk if that's the "best" answer but that's one option.
what else would wokr
why not just turn this big function into a coroutine
work
IEnumerator WaitTwoSecs() { yield return new waitforseconds(2f) }
This is actually pointless
you can just directly use WaitForSeconds
but obviously only INSIDE a coroutine
wdym "work"?
sprry was fixing my typo
They've corrected their previous spelling mistake "wokr"
oh
Thank you ill do what you said
You can also correct the mistakes by editing your message
yh lol,
hello im trying to make a fireball its not working, what is even wrong with it? I copied the code from the tutorial so i think its a settings issue or something
i dont know what you mean by "not working", i guess the position is too low?
- What do you mean by "not working"?
- We don't know what tutorial it is, and thus won't be able to predict what's wrong with the code you haven't even sent
https://youtu.be/PUpC44Q64zY?si=m33SDJBlCxRrVuYZ&t=1016 for contex thats what its suppose to look like
2D platformer for complete beginners in Unity. In this episode we're adding the ability to shoot fireballs.
➤ Starting Project: https://github.com/nickbota/Unity-Platformer-Episode-3
➤ Complete Project: https://github.com/nickbota/Unity-Platformer-Episode-4
Subscribe and turn on the notifications if you don't want to miss the fourth episode!
➤...
Well, yours aren't deactivated after 5 seconds. Is it that you're referring to as "not working"?
also the code is fine, like the issues im having is settings
yes
I don't know your settings
Looks like the issue is the position you provide in your code as the origin
Oh, it's that it isn't lasting long enough?
what?
ok ill show you
Thank you!
It looks like it is shooting from the feet, I thought that was the issue at first
okay so what do you think the issue is?
cause i dont know and it will help
is the fireball affected by gravity?
how you set its initial position when you shoot it?
The code would be the issue for that. I'd need to see it
no i set it zero
ok i dont think thats the problem but here is the git hub https://github.com/nickbota/Unity-Platformer-Episode-4/tree/main/2D Tutorial/Assets/Scripts
2D platformer for complete beginners in Unity. Added shooting fireballs in this episode. https://www.youtube.com/watch?v=PUpC44Q64zY - nickbota/Unity-Platformer-Episode-4
its in the scripts
i copied it one for one
this is the script that loads and saves the data when you load a scene the values are right player skin is the correct value but its still 0 on the player any idea why
https://hatebin.com/ierjamuwej
thats all the setting
Have you learned a lot this way?
well kind of
i need it to work for a project you see
deadline and stuff
only one data set has playingMiniGame to true
so I'm updating it's index by removing it and re creating it, Then I am overwriting it's position
but for some reason another index is also over writing it's position
since you have remove the element at i
ohh
then the element at i+1 now go to i
of course
Is the object even destroyed, or is it the animation making it disappear?
so then I now need to re-get the element with the bool to true, then set its position
Remove it from the list after you do stuff to it, and then break out of the for loop
its just suppose to display, the shooting the animation doenst work
only explosions
You haven't answered the first part of the question
You said the issue is in your bullet being destroyed too early
Well, so the explosion animation just works too early, not after the 5 seconds
yeah its suppose to show a destruction action only after the firecall is shot, so yeah
its suppose to show the fireball first
Alright, please, show your explosion animation
No, the explosion animation inside of the Unity
those were the exploding animations
The Animation component, not how it looks like in the game
maybe i show show you the tutorial video
you code wont work btw
since the item at i+1 be i now and you will skip the check on it
No, I asked you to show the animation
this is my animation? im confused
You said the object is destroyed after 5 seconds. The animation is just happening too early then.
Yes, this is how your animation looks in the game
So I need to see the length of your animation
the animation should show fire ball like in the tutotrial video, its should look like thishttps://youtu.be/PUpC44Q64zY?si=FCHEqfchSkPbHRMV&t=1016
2D platformer for complete beginners in Unity. In this episode we're adding the ability to shoot fireballs.
➤ Starting Project: https://github.com/nickbota/Unity-Platformer-Episode-3
➤ Complete Project: https://github.com/nickbota/Unity-Platformer-Episode-4
Subscribe and turn on the notifications if you don't want to miss the fourth episode!
➤...
lengnth as in speed?
Yes, the length in seconds
its 10
Do you insist on having the same logic as in the video above, even though the logic in the video works and yours doesn't?
This is the speed of the projectile
its the only speed thing here of the fireball
i copied everything i missed might have something in the settings
am i expalining correctly?
No
ok whats the issue? cause that how the speed of projectle moves in the game, the fireball is the projectile, if you mean something like animation or animator?
is this it?
Alright, I've checked the code, and the fireball is supposed to explode when colliding with a trigger, which you should've known, have you thoroughly looked through the code
private void OnTriggerEnter2D(Collider2D collision)
{
hit = true;
boxCollider.enabled = false;
anim.SetTrigger("explode");
}
meaning?
In the video above, the fireball is clearly colliding with the ground.
so its a ground issue?
So the problem is not in the, as I've assumed before, incorrect usage of the single animation, which makes the fireball redundantly fly and explode, without caring about its lifetime
so what aninimation did i not play correctly?
I have mentioned that the problem is not in the animation
Your fireball collides with the ground
so whats the sollution set the ground to something else?
It's the fireball either being spawned in the incorrect place, or having an incorrect flight angle. Or both.
what should i try?
Preventing the fireball from hitting the ground in any possible way should solve the issue for you
ok
im trying to undestand profiling. does this look problematic?
its shoots not on the ground
Sounds like it may be colliding with the player itself. Check if it is the player it hits, and if so, don't play the explode animation
Or spawn it a little further ahead of the player
how do i check?
cause i set the fire point away from player
the fire point is away from the player
the red one is where it shoots
private void OnTriggerEnter2D(Collider2D collision)
```do you know why there is a argument passed into ontriggerenter2d? it contains the data on what you have collided with
btw dont name the parameter as collision, since there is a Collision struct in unity
maybe it need to play animation when fireball hits something i think, i am not sure
To understand better, look at the hierarchy mode.
Also I'd recommend reading the profiler manual.
But to answer the question, no, it doesn't look problematic(although depends on your target fps).
ive been having frame drops when i build the game every 2 seconds or so
you think it might be some other issue?
i mean it drops to like 20 fps
or less
i made an animation trigger of fireball? on trigger it displays the explosion animation? sorry if i am just guessing i am just new,
You'll need to profile when it drops to 20 fps
or less
i recorded for 20 secs so the frame drops should show. the thing is that i dont have drops in the editor. only in the built game
thats why you shouldnt copy and paste the code especially you are new
read how the example code use the "other"
void OnTriggerEnter2D(Collider2D col){
Debug.Log(col.gameObject.name + " : " + gameObject.name + " : " + Time.time);//access the field of col
}
Then profile the build. There's no point in profiling if the issue doesn't occur.
Yes
ty
the spike goes beyond 60 fps so this is a frame drop correct?
guys i was following a tutorial and i wanted to open up a script and start coding then it said i cant, i figured its because i dont have anything to open a script with so i peeped what the guy in the tutorial was using and he was using visual studio, then this
trying to doiwnload this
wth
@calm hare i think you need to scroll down and find unity
!vs
If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
i thougt those were my onlu options
Pay attention to the UI, the scroll bar is obvious :p
I want to update my ATH with the current slot ID when i drop the item but i don't know how I can do it
They're telling you to print the object your projectile is colliding with. #💻┃code-beginner message
where
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
• Other/None
whats that
You have two open parenthesis just sitting there with no reason
wait il search it up
the world may never know
oh do i have to like download one of those
you need to configure visual studio
that won't fix your issue. but it is a requirement to get help here
alright
what have you been writing your code in if it is not an IDE ?
idk what an ide is
That's what you have google for
man im confused
and that information is a simple google search away
I need help with my code or maybe its unity but when i click play its supposed to show all the sprites on the board and I dont really know what im doing wrong. if anyone can help me that would be great here's a video of everything ive done. and its supposed to be a match 3 game https://streamable.com/pxymz7
the beginning of the video is me showing you what its supposed to do and then i proceed to show all the code and unity. im also really new to this so help would be much appreciated
jokes on you, i write my code on a sheet of paper and mail it to unity
Your issue is that what you've written in no way resembles C# code. A configured IDE will underline syntax errors and give you auto complete and make it less likely that you'll accidentally type nonsense
share your !code correctly. nobody wants to scrub through a shitty video to try and read it
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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.
il just try to write it again taking SOME things from the video
sorry i didnt know
I can guarantee that no video told you to type that mess
way ahead of you, I write my code on coding pads, then use that to produce punch cards then mail them to IBM to read into their cloud system
he did NOT warn me about that
I did it exactly like the tutorial so why does theirs work and mine doesn't" counter:
Number of times it wasn't exactly like the tutorial: 157
Number of times it was exactly like the tutorial: 5
Number of times the code literally did not exist: 1
2022-07-19 to 2024-4-18
157th
- Why wouldn't you show the code properly?
- Why is the
start, which, I assume, should be theMonoBehavior.Start, method not written from the capital?
zero index, so 158th
hi there is chat on integrating ads allowed here ?
- clean your dusty ass screen
- https://screenshot.help
- that isn't how you share !code anyway 👇
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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.
What does the exact error say
is box friend a bot?
yes
hun?
Everyone on Discord is a bot but you
we are all bots
Dead Discord Theory™️
sorry i letteraly just got into unity i downloaded it a week ago an. im trying to upload the code to one of the recommended websites
you dont had to cut me offf
Error CS1061 ‘camera’ does not contain definition ‘orthographicSize’
Blah blah blah
Do you have a script named camera
if that is exactly what it says, then you've created your own type called camera and are trying to use that instead of unity's Camera component
What type is cam? Is it Camera or some script you made?
umm i was asking could we talk on integrating ads here ?
I'm not blaming you, I haven't asked the questions for you to tell me you've downloaded Unity a week ago
so did you go and read the Camera docs to see what you should be using or do you think you can make things up as you go along?
Sorry, my computers modem broke down and I can’t send code
And Gemini also told me the same thing
Why don't you merge all your sentences in a single message for no one to cut you off?
well for starters, i was responding to someone who posted before you. so if you think that there is some sort of queue for getting help, then you cut someone else off. and second, use #🔎┃find-a-channel to find a relevant channel to ask your question in. and third, https://dontasktoask.com
Answer what was asked. Do you have a script called camera?
Hey, so adding of the hero works fine but when I try the removehero function it just doesn't work and gives no errors.
public List<GameObject> heroSlots = new List<GameObject>();
public void AddHeroToSlot(GameObject hero)
{
foreach (GameObject slot in heroSlots)
{
if (slot.transform.childCount == 0)
{
GameObject newHero = Instantiate(hero, slot.transform);
newHero.transform.localPosition = Vector3.zero;
break;
}
}
}
public void RemoveHeroFromSlot(GameObject hero)
{
foreach (GameObject slot in heroSlots)
{
if (slot.transform.childCount > 0)
{
if (slot.transform.GetChild(0).gameObject.GetInstanceID() == hero.GetInstanceID())
{
Destroy(slot.transform.GetChild(0).gameObject);
break;
}
}
}
}
}```
Ok, so what type is cam ?
okay so heres all my code
this is the Row.cs
https://hatebin.com/mppoqodykd
ItemDatabase.cs
https://hatebin.com/ggepycdbdi
Item.cs
https://hatebin.com/dymbrwmlqa
Board.cs
https://hatebin.com/fplbqqcuqr
Tile.cs
https://hatebin.com/kpahqamloz
I did answer what he asked, no, this code is placed in a code named “enemy” not sure why this is relevant tho
Please, consider posting long code blocks on the recommended sites !code
Did you drag in the script asset, or an object WITH the script?
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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.
That is not an answer to what was asked
Again, what type is cam?
can someone help me with integrating ads !!! plz ! the unity page doesnt help i have tried it many time
an object with the script
Is the thing you've dragged in to that function the exact object in the hierarchy you want to remove?
Public camera cam;
sorry my bad
What is camera?
I know of Camera
you sure it is camera not Camera ?
you dont have to post a big message like a bot bro
What's camera?
Stop
It doesn't look like you're every adding the new heros to the hero slot list so there isn't really anything to ever remove.
I have a prefab in my assets folder and I placed it there, how can I remove the prefab/object that is in the hierachy
You said “do you have a script named camera” I don’t
and you don't have to be obnoxious bro
yeah this is the thing that I don't know how to do
You said you wrote camera. There is nothing called that in Unity
There is Camera though
can I try to use a tag?
can a proffesional review my code pls
This
That is Camera, not camera
So, your function would check if that prefab is in the scene, which it never can be. You can't check if an object is an instance of a prefab, you'll need to get some sort of name, tag, or variable on it
No, that's Camera. What is camera?
Your adding of characters is incomplete.
Whoops, forgot what channel we're in, sorry.
Try in #archived-code-general or make a thread
ohh
https://screenshot.help betta
yeah I was actaully thinking of tag
yeah now i got it
if you want help with your code, you'll need to post it. if it's a long block then use a bin site like the bot shows below !code
and it's generally good to have something specific to ask about, even when asking for code reviews
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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.
Usually it tells me that I have a problem in where I made the variable, wierd but it works
Then you likely have a script called camera. Or your ide got unconfigured
You have made a script named camera. That script does not have anything named orthographicSize
You can absolutely make a variable of type camera if you have one. That's perfectly cromulent C# code
is the GetInstanceID() needed?
Only if you want to check if two things are the exact same instance
don't look this message I found the solution
Ohhhhhh
okay now its clear
thanks :D
does someone know why my character is spassing out when I changed update to fixedupdate??
in my movment code
show code
wdym by spassing out
Not without seeing code of course
code seems to be good from my experience but imma show
It's probably fine then
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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.
Large code blocks #💻┃code-beginner message
if only there were instructions for posting large code blocks
Then do the large code block section?
..I wonder where would one find such instructions
using UnityEngine;
public class PlayerController1 : MonoBehaviour
{
public float moveSpeed = 5f;
public float jumpForce = 10f;
public float lookSpeed = 2f; // Camera rotation speed
private Rigidbody rb;
private Transform playerCamera;
private Vector3 moveDirection;
private float rotationX = 0f;
void Awake()
{
rb = GetComponent<Rigidbody>();
playerCamera = Camera.main.transform;
Cursor.lockState = CursorLockMode.Locked;
}
void Update()
{
// Get the player's input for movement
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
// Calculate the movement direction based on input and camera orientation
moveDirection = moveHorizontal * playerCamera.right + moveVertical * playerCamera.forward;
moveDirection.y = 0f; // Keep the movement only in the horizontal plane
moveDirection.Normalize();
// Rotate the player based on the mouse movement
RotatePlayer();
// Move the player
MovePlayer();
// Jump if the spacebar is pressed
if (Input.GetKeyDown(KeyCode.Space))
{
Jump();
}
}
void MovePlayer()
{
Vector3 movement = moveDirection * moveSpeed * Time.deltaTime;
rb.MovePosition(transform.position + movement);
}
void RotatePlayer()
{
float mouseX = Input.GetAxis("Mouse X") * lookSpeed;
rotationX -= Input.GetAxis("Mouse Y") * lookSpeed;
rotationX = Mathf.Clamp(rotationX, -90f, 90f);
// Rotate the camera vertically
playerCamera.localRotation = Quaternion.Euler(rotationX, 0f, 0f);
// Rotate the player horizontally
transform.rotation *= Quaternion.Euler(0f, mouseX, 0f);
}
void Jump()
{
rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
}
}
plz identify potential areas of improvement in this cod
Maybe you ought to tell people what's not working?
its not a "Code not working channel"
You should be acquiring input in regular Update
well then the game glitches out and throws me out the world
Consider decoupling the logic from the acquisition of input.
just asked if i can improve the overall experience of the player with any changes in the code
with regular update?
They'll never see the code-base. Use the profiler when optimizing/finalizing.
the player doesn't see the code
if it works, it works.
And what player experience are you seeing is the case that isn't doing what you want?
anyone know why this isnt working if you need me to send anything else like other scripts or smth lmk
wanted to ask that how to make the game go smoother and better for all divices
You'd run the profiler and see where you're spending cycles.
https://docs.unity3d.com/Manual/Profiler.html
i quit code il take a step back and go on scratch for the first time in 7 years
didn't know about it thanks for the help
Maybe show your logs to prove that everything should have saved and loaded fine.
are you talking about the start in Board.cs
this is the Row.cs
https://hatebin.com/mppoqodykd
ItemDatabase.cs
https://hatebin.com/ggepycdbdi
Item.cs
https://hatebin.com/dymbrwmlqa
Board.cs
https://hatebin.com/fplbqqcuqr
Tile.cs
https://hatebin.com/kpahqamloz
In Board, what calls start?
like the console?
Button[] buttons;
for(int i = 0; i < someLength; i++) {
buttons[i].onclick.AddListener(delegate {
Debug.Log(i);
});
}
this always logs the value on i on last iteration. how do i make it so that the iteration number(i.e. what was value of i when listener was added) is logged instead?
Lambda captures. My nemesis
yeah though that this question was really stupid. makes sense
Boxfriend has the link, but I just want to point out that no matter how many times I know this happens I always step on that rake
Add this line: cs Debug.Log($"{player.name} was successfully loaded",player);after the skin message
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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.
int ix = i;
problem solved
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Clicking the message should highlight the object successfully loaded in the scene @amber spruce
okay so I tried doing something like that
as you told
dont know how really
but i tried
and it still doenst work
public void Load()
{
string saveString = SaveSystem.Load(saveSlot);
if (saveString != null)
{
SaveObject saveObject = JsonUtility.FromJson<SaveObject>(saveString);
if (player != null)
{
Debug.Log(saveObject.currentSceneName + " Save slot " + saveSlot);
if (saveObject.currentSceneName != SceneManager.GetActiveScene().name)
{
//SceneManager.LoadScene(saveObject.currentSceneName);
}
player.GetComponent<PlayerHealth>().currentHealth = saveObject.playerhealth;
player.GetComponent<PlayerHealth>().Heal(0f);
player.GetComponent<PlayerControllerNew>().Skin = saveObject.playerSkin;
Debug.Log("Player Skin: " + saveObject.playerSkin + " Current Scene: " + SceneManager.GetActiveScene().name);
Debug.Log($"{player.name} was successfully loaded", player);
if (SceneManager.GetActiveScene().name == "SinglePlayer")
{
player.transform.position = saveObject.playerPosition;
}
}
}
else
{
Debug.Log("No Save File Found");
}
}
so like here?
well naturally that won't work. you need to store the result of the input in fields so that they can be accessed in those other methods instead of just letting compile errors stick around
Well, how're the variables from Update going to be used in the other method if they're only local to that method?
also you should 100% be doing the rotation in Update rather than FixedUpdate. you're missing a lot of mouse input by doing it in FixedUpdate
are you have a specific problem?
many resources online how to do this
When you move x distance, spawn a new background
That is one of the many manh ways
yeah I have no clue for me this should work
but it doesnt
I tried having no fixedupdate
and I flew
tried fixed
now I spass
Please finish a message before hitting enter
Could probably
for "unity 2d parallax"
okay sry
interactive
public GameSaveModel SaveCurrentGameState()
{
var model = new GameSaveModel();
_savableServices.ForEach(service => service.SaveGameState(model));
return model;
}
Do the services that alter the model object, alter a copy or the reference to that object? Because a value of it is null despite being set by a service
Is GameSaveModel a class or a struct
if its reference type ur modifying the same object
how does that help?
i can find the object
To ensure you're modifying the correct object
It'd prove that that specific log is being printed by that specific object
It's a class
so yeah im modifying the right object it just seems not to change the skin
how do you know model is null, it could be _savableServices or one of the service
Well, it's certainly not related to code then as those lines of code have been executed and the correct data has been assigned appropriately to the correct object in the scene.
Then it's passed by reference. The model variable holds a reference to an object and other things referencing the same object will share data
then what would it be?
[Test]
public void ActionBankIsSavedToGameSaveModel()
{
new ServiceManager();
new ActionService();
new TurnService();
ServiceManager.Instance.InitAll();
var model = new GameSaveManager().SaveCurrentGameState();
Assert.IsNotNull(model.GameActionBank);
}
Message:
Expected: not null
But was: null
Something else.
Hm yeah I thought so. Seems the issue is elsewhere then
Can you show an image of the correct object in the scene highlighted when the message is selected?
I'm not sure what's the purpose of creating a GameSaveManager, then calling a function on it that returns a different GameSaveManager
yep 1 sec
The save manager yields the model, not another manager
The model will later be parsed into JSON and then into a file
Oh, right, similarly named but different
There's an error btw.
So then model definitely is not null. model.GameActionBank probably is, where does that get set?
Other than that, you've saved again immediately after loading, perhaps some things have occured after loading.
https://paste.ofcode.org/34CDwvEMQ5CjkhPcrXtFPHe so I tried changing the locations of inputs to update instead
not it kinda works, but I acelerate really fast
so I become reeeallly fast
Hey, not really sure where to put this but I'm having an issue where I can't left or right click anything in the Scene view (I also can't move or rotate with the shortcuts)
All the answers online say to switch from Iso to Perspective, but I'm already in perspective mode
I tried closing scene view and making a new one, no luck, and this issue affects every scene
I've also tried of course closing it and opening it back up, restarting my computer
If anyone could help that'd be great, my project is pretty much stuck until I can figure this out
well yes, you are now using a deltaTime value that is likely much larger than the time between frames you are actually calling CC.Move
you were meant to separate the input from the movement, handle input in Update and movement in FixedUpdate
ohh okay Imma try
Dude, you only need to poll input in Update and do all of the necessary logic elsewhere.. excluding those that should be done in Update as well.
node a code question #💻┃unity-talk
great thanks
yeah man I don't really understad what you mean
For example:cs private float vertical; private float horizontal; private bool jump; private void Update() { vertical = Input.Get... horizontal = Input.Get... jump = Input.Get... }
tried putting input in update and movment in fixed but only errors
so even in the save file the playerskin is set right the problem is it doesnt wanna set the players skin to it
let me guess, you didn't bother thinking about how to separate the input from the logic and instead just decided to try using local variables again
show the code
I'm sure the values have been assigned if the messages have stated so. Likely you've reassigned it elsewhere in code to something else.
yep i found it
it was in the start function of the player controller
i was setting it to a playerpref that i was using before i set up the save and load stuff
thanks
okay so I have seperated them this time but Now I am shaking again and it is kinda weird
When does it shake? Rotating, vertical movement, horizontal movement, jumping, etc
Also describe shake better or show a video clip
When IDLE?
yuh
Maybe it's not related to these lines of code or your character isn't ever not moving.
Or the camera is just screwed up
Hello there,I'm sumesh ... can anyone suggest to me on how to build 2d beginner games using unity game engine, thanks in advance
okay I think I know
so the character controller want my player obj to fly up the sky
while my script has gravity
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
so it is a constant up and down
I've been watching a video on how Super Mario 64 detects floor, wall n' ceiling and it uses the triangle's Normal Vector to do so. Basically if the Normal Vector is pointing down, it's a ceiling; upwards, it's a floor; and if it's straight, a wall.
I was wondering if I can get this information on Unity and get the Normal Vector Rotation/Orientation from a model's triangles/faces to apply the same logic seen in SM64.
for the specific type of game you're wanting to build, for example: unity 2d flappy bird
oh. they crossposted it everywhere 
||But first we need to talk about parallel universes||
The Dot Product of two vectors gets you the "sameness" of the vectors. It's 1 if they're pointed in the same direction, -1 if they're opposite, and 0 if they're perpendicular. The way SM64 likely does the check is to dot product the wall's normal with world up. If it's greater than something like 0.9, it's a ceiling. If it's below -0.5, it's a floor, and otherwise, it's a wall
Question, does anyone even check the #⛰️┃terrain-3d channel? Me and others are having problems and like no one responds ever
all you have to do is scroll up to find out, yes, yes they do. And don't dirty this code channel with off topic questions like that
Sorry, this was the only active channel I could find at the moment
someone know why my character controller and script interupts eachother, character controller want character to go up while script wants to go down https://paste.ofcode.org/He5CNsd5KrdsDAdid2KgLt
A CharacterController only moves when you tell it to. It doesn't respond to physics, it doesn't have gravity
||GASP you're 4 parallel universes ahead of me!||
If the controller is moving in a way you don't want, it's because you have a .Move call somewhere you shouldn't
||16 actually this is just my quarter-step check||
is rigidbody based movemnt actually better then character controller
there is no "better" tbh
they both have their use cases
Either are as good as you make it. Though typically people will make their own custom controller (or use kcc on asset store) instead of the built in character controller
well as you can see the thing is broken
im thinking of cc for a fps
Character Controller offers similar control of Kinematic RB without having to deal with no Collision / phasing through walls and having to do manual checks like casts
i did make mine rb based
but its quite janky so im trying the cc
fighting forces is not fun
yeah rbs should not be moved in Update
also why assigning velocity in Update and FixedUpdate?
meh idk im trying to make it super moduable
so should i put everything with rb in fixed
someone?
No idea what that means or how that would help here do that
Hi i just formatted my pc and i want to download vscode extensions can you guys send me link to the extensions that i need
ideally rigidbodies should only be moved in fixedupdate
ah ok
if you don't want to deal with fighting forces just use CC
but imma make both a cc based and a rigidbody script tbh
I make things like acceleration manually anyway
Animation Curve would be your best friend for achieving nice movement
Follow the guides from !vscode
Yes, the start method in the Board.cs is what I'm talking about
because !vs and !vscode both have vs the bot doesn't differentiate between the two
poor dyno 😢
stoopid dyno
I HAVE FIXED code kinda but now I am stuttering when looking around, movment works tho and I can kinda look around
so do someone know how to fix this problem
are you still only performing your rotations in FixedUpdate
i want to change the version of my project to and older one
I think I put the inputs in the update and the rest in fixedupdate
so the inputs from rotation into update and logic into fixed
so you remember how i pointed out you should be doing the rotations in Update so you aren't missing input from your mouse?
just change the version.. make a backup first 👍
yo i didnt back up :(
should be fine
i found out before you answered XD
yeah I know thats why I put the inputs in update and the rest in fixed
as you can see in the code
you didn't share the code?
So I have an audio manager, where I want to switch between the music "Phases" like a lot of other games. The problem is, when I try playing the music when the player crosses a trigger, it changes the track in the audiosource, but nothing actually plays. The "BeforePhaseOne" Plays, and changing it in the editor then playing the game does play the audio. Just for some reason the code doesn't play when it switches (BTW I'm using a mediator to communicate when to play the song phases)
and also i said to perform the rotation in Update, not just get the input for it in Update. because i can guarantee that if you are just getting the input in update you aren't properly accumulating the mouse's change in position since last FixedUpdate hence the stuttery rotations since you get 1 frame of rotation 50 times per second instead of every frame
!code 👇
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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.
alr trying right now
the game is still stuttering when rotating, for some reason when I pause the game and I move the mouse button the game looks around with no stutter
I changed what told me to and it created an error in unity
then you should post it
Im trying something now but if i dont get it then ill post it again
someone??
You seem to he rotating a transform, but you have a rigidbody. Rotate the rb instead
Also do it in FixedUpdate
how do I do that???
never tried rotating rb
I have 3 star images and they scale the way I want but I want to stagger them
hey! I'm basically a complete beginner but I'm trying to make a game for a class and need to make a tutorial. I have a "next" button on a panel, and when you click it I want the panel that is currently showing to be disabled and a different panel to become enabled, repeated for a couple more panels, almost like flipping through a book. could someone help me with that? I've tried searching for a long while and nothing helped!
What have you got so far?
If each "page" is a different panel, you can use the OnClick for the button to disable the current panel and enable the next one
Basically the exact same, but instead of writing transform you write your reference to the rigidbody.
Same method you're using though
i have all the panels set up with the buttons, I just need to configure the buttons to disable the current panel and enable the next panel
so your google should be something like -> "unity how to disable a gameobject with a button"
ah that makes sense,, how would I do about doing that? this is my first time with c# unfortunately
https://gdl.space/tekujokudo.cs
I can't get the ProBuilder Mesh that I create in this script to become visible.
I followed this tutorial:
https://www.youtube.com/watch?v=RdnfidIaGqc&t=67s
As best as i could.
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...
Do you know how to add a function to a button's onClick?
The answer is in the first result of what you were told to google 😉
the probuilder channel only refers to the editor and scene view
{
rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit);
playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0);
}
rigidbody instead of transform??? or should I have it some where else bc when I place rb there it gives me error and I only have problem with rotation so I don't think I need to change movement??
what's the error?
Figured it out, turns out you need to play the source after changing the music, so I added "Source.Play()" and it works now
Well when i run the build I can move around without any problems but my camera movment is stuttering, so I am figuring out how to fix that
but I have no clue on how to do that
Ah yeah, you're using localRotation. Rb has .rotation
I looked at the first result and it didn't help any,, sorry
yeah I have no clue how to fix that...
plus button to add to the list then drag the script in?
you could try lerping the value of rotationx and see if that helps?
Well you have the word localRotation
Instead have rotation
oh
I got error, Severity Code Description Project File Line Suppression State
Error CS1061 'Transform' does not contain a definition for 'Rotation' and no accessible extension method 'Rotation' accepting a first argument of type 'Transform' could be found (are you missing a using directive or an assembly reference?) Assembly-CSharp, Assembly-CSharp.Player C:\Users\gottc\My project (1)\Assets\Objective system\CharacterControllers\FPSController.cs 69 Active
https://docs.unity3d.com/ScriptReference/Transform.html
Do you see any properties or functions named Rotation
You still have transform. And you capitalized rotation
The whole point of this was to switch from transform to rigidbody...
How do you get a mesh made through a probuilder script to render?
{
rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit);
playerCamera.rb.rotation = Quaternion.Euler(rotationX, 0, 0);
}
Severity Code Description Project File Line Suppression State
Error CS1061 'Camera' does not contain a definition for 'rb' and no accessible extension method 'rb' accepting a first argument of type 'Camera' could be found (are you missing a using directive or an assembly reference?) Assembly-CSharp, Assembly-CSharp.Player C:\Users\gottc\My project (1)\Assets\Objective system\CharacterControllers\FPSController.cs 69 Active
it does.. it gives step by step instructions how to setup exactly what you're doing
https://forum.unity.com/threads/how-to-hide-or-unhide-gameobject-with-button.444040/#post-2871966
Yes, do not get it via camera
assign rb= getcomponent<rigidbody>()
I tried but only error
https://docs.unity3d.com/ScriptReference/Camera.html
This is every function and property on Camera. Do you see anything named rb?
how
If this is the camera object, and it does not have a rigidbody (should not) then it is not an issue to rotate via transform
It is a different issue
Try doing what you did before, but in lateupdate
so changing fixed update to lateupdate?
An object with a Rigidbody should be moved in FixedUpdate. A camera should be moved in LateUpdate.
rotation input too?
ah, that wasn't the one that came up for me. I'll try that one!
Input always goes in Update regardless
if (proMesh == null)
{UnityEngine.Debug.Log
("Mesh Failed");}
else if (uIPoints == null)
{UnityEngine.Debug.Log
("Points Failed");}
else{string log = "";
foreach (Vector3 point in uIPoints)
log += "(" + point.x.ToString() + ","
+ point.y.ToString() + ","
+ point.z.ToString() + ")\n";
UnityEngine.Debug.Log(log);}}
I'm trying to debug the reason why the meshes won't show up and it seems like the points aren't being created:
movment works fine and all but rotation stutters a LOT
if it's rapid fire stutter, see if lerping will help
what is lerping??
it's basically a smooth transition between variables
where should I place it?
you could put it directly in the Quaternion.Euler statement
hello, is each added function of a button run in a cycle per click or do all of them run at once ?
They run top to bottom each time you click the button
well not once but sequentially
Im trying to make it to where it constantly makes it to where it goes up by 10. I keep getting this error but I don't know how to fix it.
InvokeRepeating takes the name of a function, a time to start, and a repeat time
Oh.
So then why did you try to call it with just a string
OHHH
how come when I have the set active ticked off for the last function still not show the pause menu tho ? When I was trying to 'debug' this, i thought that sequential run thing might be why but this still doesnt work
srry i live in a area with major allergies and I got allergens which make me forget everything and lose my appetite.
I dont have any code messing with the canvas yet either, most of this is the basic canvas
You appear to be disabling then enabling the same object
so end result it's going to be active
Show this screenshot after clicking the button while in play mode. Include the hierarchy
If you are lokkin side to side you might need to use rotation.y instead:
Quaternion.Euler(Mathf.Lerp(rotation.x, rotationX, Time.deltaTime), 0, 0);
And this is after you clicked the button?
Does the button respond to being pressed? Like, do you see it animate?
And are you sure you're clicking on this one and not the PauseButton (1)
How do I disable the stroke and panel when lifting an item?
{
rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit);
playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0);
}
``` ??? where do I put lerp
I was tryna figure it out but no work
you replace the quaternion.euler statement with
Quaternion.Euler(Mathf.Lerp((float)rotation.x, (float)rotationX, Time.deltaTime), 0, 0);
the whole segment???
This is what they refer to as wrong lerp
or just after =
just replave this
Quaternion.Euler(rotationX, 0, 0);
oh alr
after the equals
First and second parameter of lerp should be unchanging, and third should move smoothly from 0 to 1
Use movetowards for this.
Help guys
I finally got it!!
yeah
(float)rotation.x ..?
That rotation also better be a vector and not a quaternion.
check my request
it's usinf mathf so it needs to be casted as a float, the goal is to take the current x and lerp it to the expected x rotation.
The lerp you showed was very incorrect
Why not just movetowards?
Or smoothdamp?
rotation.x is not the degrees about the X axis
That line is very wrong in several ways
yeah i'm dumb rotation is a quaternion
And you think the x component isnt a float?
can chessagon? yes you can!
watched that CGP video of it again yesterday, good stuff
pawns look really decent too, gj!
free asset, low poly chess
unity store
Vector3 SnapToGrid(Vector3 position)
{
float snappedX = Mathf.Round(position.x / gridSize) * gridSize;
float snappedY = Mathf.Round(position.y / gridSize) * gridSize;
float snappedZ = position.z;
return new Vector3(snappedX, snappedY, snappedZ);
}
i have this snap to grid function but as you can see it has weird functionality when applied to blocks bigger than the grid, what should i do?
Pay attention to the pivots of your sprites and make sure they're all set up for this
https://gdl.space/wewedibimo.cpp
Here's my camera rotation code if it helps. the rotation input is different, and the camera is locked around a center position, but it's not as stupid as what I typed before
ill try that and get back to you
Hey guys. So I am trying to make a "platform system" to help 2d developers make mods.
But when I hold E down it flashes immediately and goes away. I just want it to where if people press E then it stays there till they let go.
Here is my script:
using System.Collections.Generic;
using UnityEngine;
public class Mods : MonoBehaviour
{
[Header("Platforms")]
public GameObject platform1;
public GameObject platform2;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown("e")) {
platform1.SetActive(true);
platform2.SetActive(true);
}
else
{
platform1.SetActive(false);
platform2.SetActive(false);
}
}
}
Can someone help, keep getting this error and i dont understand it
yeah I replaced but it does not work
Something on line 23 is null but you're trying to use it anyway
undo that I said a stupid
What is line 23
{
rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit);
playerCamera.transform.localRotation = Quaternion.Euler(Mathf.Lerp((float)rotationX, (float)rotationX, Time.deltaTime), 0, 0);
}
my bad
Game volume
So either volumeSlider is null or it doesn't have a Slider component
Cool let me see
You're deactivating them every frame in Update
you know somehting else that might help?
so take it out of update and put it in start?
or just put it outside both of them?
Huh?? No.
The else part happens every frame except the one where you press the key
Use the right conditions
movePoly.transform.rotation.eulerAngles.x
this should be the right way, right?
okay thats a start, just got to get them back to the bottom left of their grid position
If you still wanna try the lerp,
transform.rotation.eulerAngles.x
should work in place of the first variable
I was trying to call the x directly out of the quaternion which was my mistake
Help guys
``` here??
void HandleRotation()
{
rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit);
playerCamera.transform.localRotation = Quaternion.Euler(Mathf.Lerp(transform.rotation.eulerAngles.x
, rotationX, Time.deltaTime), 0, 0);
}
that should work i think
I think I fixed it by making if key up
trying rn now
nvm
idk what to do
So, both platforms will activate on the frame you press e. What's the issue?
I want it to where when you stop pressing e it goes away
yeah rotation still not workin
I used a else statement.
Failed.
So you should add code that does that
Whenever you release the key, deactivate them
u can say else{ platform1.SetActive(False);}
Else on GetKeyDown is NOT going to tell you when the key is released
inside the input class there is one
That will deactivate them on every frame that e has not been pressed
Which is not what they want
u can switch to GetKey
and it will do exactly that
uh oh
while e is pressed it will be active and when released it will deactivate
That will also be constantly calling set active every frame
better to just set it on press and release
it doesn't say Release is a thing.
Because it isn't. Did you try checking the documentation
ofcourse , u need to then create a bool to check current state and switch it based on current state
Or, again, you can just set it on press and release and not need one
that would force him to hold button so its just different setting there, depends what he wants to achieve but yeah
what?
im so confused
🙂 google is your best friend

show how you wrote
it will work
if (Input.GetKeyUp){
platform1.SetActive(false);
platform2.SetActive(false);
}
You should actually look at the documentation
That's not how you call a function
u need to say which key
i got confused
alr i got it done.
Whats better?
Import all of the guns into the scene and deactivate them. And switch them on and off in the script, when i switch my weapon, or should i create a new gameObject, with the weapon, when i switch the weapon?
Or do you have a better idea then both of these methods?
activate and deactivate them
makes it much easier, you can also preset the locations and variables and anything you need
Alright, thank you! 🙂 @deft grail
my anchors have gone missing from some of my canvas elements, although the toggle's anchors still show up
thats because something else is controlling it i think if i remember right
is it even inside a canvas component?
wdym, how can i reenable
like the child of CharacterSlots maybe?
whats there
wdym, I think the picture shows Canvas having the pausedinventory which childs the character slots
these 5 objects
but not the white background itself
/image
is puased inventory a regular transform or rect ?
also idk i never assume, it just says Canvas but doesn't tell me Canvas component is there
those slots however do have anchors
but like what actually are they, whats the inspector of them
are they just an empty game object?
Help guys
was there like an update or something because yesterday my code was fine now theres like 40 errors
unity editor doesn't update unless the whole app was replaced with new version, deliberately by you
never mind i fixed it
i believe just a UI - image
same thing as the character slots parent
paused inventory is an empty game object to disable/enable the entire pause menu. The actual Grayedbackground and inventory/character slots are also just UI - image
didnt answer the original question
sry, rect
also this isnt code related
2 people responded, u included, and we were already having a conversation going
just create a new object and see if work
but ok, ill go to UI
I want to understand why tho
is unity that buggy? It crashed earlier when I hid a samplescene gameobject lol
nvm. Did you maybe use layout group or something ?
sry idk what layout group is. When i was trying to figure it out myself I was worried that I might have accidentally clicked something I shouldnt have but I cant find the difference between the ones that do show anchors and dont
but ur right, just have to spend another 20 minutes adding in a few blocks again
is probably the best approach
@rich adder
https://hastebin.com/share/leropecawu.csharp heres my player movement script
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
let me know if you have any clue whats causing the issue and i'll get to fixing it
rb.MovePosition will phase thru objects
so should i remove it?
dynamic rigidbody should either use addforce or velocity, or switch to character controller
If I don't have an object on Scene the animation events don't show the dropdown menu to attach methods; even if I am not selecting a object on scene and just like modifying the animation controller directly, can I still manually write the method and it does work?
These are the two different UIs that I am mentioning, just to be clear
Thread
Yeah, I usually wind up doing the latter anyway
It will send a message named DeactivateDamageCollider to the object the animator is attached to
so any method on any component on that object whose name matches will get called (if the type signature is right, at least)
Oh, cool then, thxs
20 Ms? That should be a hitch, but probably not very noticable. It seems like the CPU is waiting for the GPU to complete it's work.
perhaps something else was using the GPU at the time and caused a delay
Yeah, that's a possibility
I have a trail renderer on my bullet. When e.g. there are 3 bullets active in the scene, because i have a high fire rate. The trail renderer renders a trail to every single bullet, when i shoot. How can i render this trail once for every bullet?
A trail renderer will draw the movement of whatever object it's attacked to. If each bullet has a trail renderer, then each bullet will render a trail
So i have to use effects for the bullet trails?
If it's bullet trails you want, trail renderers are fine. What is the issue with them
The issue is, when i shoot and turning around it looks buggy, when one bullet is close to you, the other is further away and so on. Then the bullet trails become triangles and stuff like that, because it renders the trail from every bullet active in the scene, everytime i shoot.
"rendering the trail from every bullet" seems like exactly what you want to be happening
Why wouldn't each bullet have its own trail?
No, thats fine. But when i shoot, the trail gets rendered again and then it looks weird.
I don't know what you mean. That seems like exactly what you'd expect out of bullet trails. What's "weird"?
Its like they always try to get the trail back to me. So when i move and a bullet is already out and i shoot again, the bullet trail is buggy
Adding a wait for second anywhere that is not on a Coroutine does something or do I have to specifcially create a coroutine to wait for seconds?
Like lets say I want to wait for half a second at Awake to do X
A trail randerer will trace the path of the object it's on
WaitForSeconds needs to be in a coroutine
Start can be a coroutine
If it returns IEnumerator it'll be run as a coroutine instead of a normal method
How? Do I make it an Enumerator?
Thats what i mean. The left trail was created as i was shooting. Yes, in this direction i shot a bullet 1 second before, but the trail was already invincible. But as i shot the right bullet, another trail was created for the left one.
I can make start a coroutine but not awake?
Are these actually trail renderers? Show the inspector for one of them
There'd be no point to making Awake a coroutine. The point of that one is to run immediately without waiting for the Update loop, but Coroutines are only checked during the Update loop
This is on the bullet gameObject
If Awake were a coroutine, it'd just become Start
Okay, yeah, that seems fine. So it'll trace a path the bullet takes and gradually thin out into invisibility
Right. When i shoot 1 bullet, its fine. But when i shoot another, while there are more then 1 bullet active in the scene. It looks weird, because the already invincible trail is rendered again.
Thats super confusing
Is there a way to reference the standard shader when creating a material?
If the trail has already faded, it's not going to light back up again unless you have code that does that, or you move the object
Shader shader = Shader.Find("Hidden/Internal-Colored");
Something like that
oh, but you probably need some extension script to call it
when calling the assetdatabase
ah really
I have no code which affects the bullet. Only on impact, the bullet is set to inactive
Show the code where you're spawning the bullets
https://docs.unity3d.com/ScriptReference/AssetDatabase.CreateAsset.html
The docs actually gives you an idea with your exact requirements
Actually, if these bullets are pooled, then you are moving the object. When you reactivate it, it'll draw a trail from where it was to where it currently is. Part of pooling the object should be clearing the trail renderer:
https://docs.unity3d.com/ScriptReference/TrailRenderer.Clear.html
They are pooled
the core premise of object pooling is that you can get away with doing less than completely destroying and recreating an object
however, this means that you are now responsible for making sure that old data doesn't stick around
So, disabling an object with a trail renderer is not stopping the trail, it's pausing it
(and that old references aren't being kept!)
You need to clear it before you re-use it
I will try that out real quick
I'm not trying to create a new shader, I just want to create a material. But the constructor needs a base material or shader as a parameter so I want something I can put in without having to use resources.load shader.find
The code Mao linked does not create a new shader.
It creates a new material.
Every material must reference a shader, though, which is why it's using Shader.Find
so unity doesn't have a path to the default shader without using find?
sadge
i was hoping it'd be a built in variable/instance i could call
cache em at the start
well, I mean, the AssetDataBase is for editor specifics if that's what you were wanting
which shouldnt really matter about it being a string lookup
the only nuisance is that you need to pick the right shader for your current render pipeline
I was hoping to use the standard one used in game view and scene view
If I want to like have 3 different sounds for the same thing and pick one of them at random do I need 3 AudioSources or is there a way to store the clips on a LIst and then attach that to the AudioSource before playing it?
use an array, you can then set the audio source to play one of these clips
the array will just hold the sounds
not any AudioSources
Alright. It worked. Thank you very much! 🙂
So something like that?
yeah
my visual studio cursor is weird and instead of adding new stuff, it hovers over code and replaces the code with new code, not a good explainer but hopefully u guys will understand
press insert on your keyboard
oh sick thanks
how do i fix this
CollectObjects doesnt have a method / property defined in it Called MarkedWithModifier
Same with the two NavMesh Classes
how can i delete thos scripts
might be some package broken
the errors show exactly where they are.. but u shouldn't just go delete scripts here and there from Unity packages. it'll just end up throwing more errors
if u want u can remove the entire package.. but thats not gonna do u any good if u wanting to use it
did you install the AI package from git or from package manager
git
i just draged and dropped the assets
should i just reinstall from package manager
delete old first yea
Always use the package manager when possible
navmesh agents are pretty easy to get started
navmesh are the easiest
alright thanks guys
giving it good variations is a whole different beast 😅
i cant find navmesh on package manager
its should be called AI
should be i use 2023 so im a later version
seems to be same of what you had before though so not sure
yeah it is
A quick but kinda specific question, an AudioSource plays at the origin of the object right?
if you have 3D sound on
if its set to 3D spatially the origin of the source itself yes
i cant find any other one than this
unless im in the wrong place
yeah looks fine, idk try installing it again then
i did it gave me same errors
my latest was 2.0 so i got confused for sec
What if I wanted to be on the closest point of the object then? Imagine like a really streched out mesh that should be heard equally as strong at any point near the whole mesh? A laser for example
Can I do that?
can you send me a link to yours cause it doesnt appear at all
mine wont work for yours, I'm on unity 2023
anyway something else is wrong if you installed that package and got those error
should i update unity to 2023?
no
then im not sure what im doing wrong
try reimport all assets, under Assets menu
why are you crossposting
because
im a begginer so i did one min here to
yo im making a open world zombie shooter like wwz if anyone wants to help!

stop spamming
im not?
you were already linked to where to ask for collab posts
yo someone has nothing better to do lol
adhere to the rules or scram
What a good way to get blocked by everyone who actually helps around here.
so i cant ask for help?
ask a specific thing then about code?
you know what im leaving this server
If you have a question on topic for this server, then ask if. You were told where collaboration posts belong.
You can ask a collider for the nearest point on its surface
You could then position the audio source there
Trying to detect controller in unity with:
foreach (string joystick in Input.GetJoystickNames())
print(joystick);
but it prints an empty string, though I do have a controller connected and it can play the game
just use the new InputSystem, would be much easier
no other alternative? I've already got pretty much all logic done for the inputs, and am yet to learn about using the new input system
Why do people always think they're the main character?
They don't have to announce that they're leaving, no one will notice anyway
I only need this detection to automatically differentiate controller types so the player wouldnt have to tell the program manually what controller type they'yre using through a toggle or button
so your trying to like display controller inputs or something?
Well, I learned that the old input system maps binds differently to different controllers, so I automated this binding, but I have a variable which tells the program which controller type they are using
I wanted to be able to set this variable automatically depending on what the string returned by Input.GetJoystickNames() contains
Something like this for example:
if (joystickName.Length > 0)
{
if (joystickName[0].Contains("Xbox") || joystickName[0].Contains("XInput"))
{
isXbox = true;
}
}
the docs say you need requires you to set up axes "Joy0X" - "Joy3X" and "Joy0Y" - "Joy3Y" in the Input Manager, do you have that setup?
I haven't heard of those before, so I'll check it out, those need to be set up for Input.GetJoystickNames()) to work?
maybe not, but thats what i see on the docs could be linked to the other line though maybe
https://docs.unity3d.com/ScriptReference/Input.GetJoystickNames.html
Thanks, I'll try it out
for (int i = 0; i < 4; i++)
{
Debug.Log(Input.GetJoystickNames()[i]);
}
``` i done this from the docs
works fine
can actually just do 0 instead of the i and remove the whole for loop, and works the same way
Yea it just returns empty for me for some reason, could be my controller
yeah maybe, i just opened a project which has absolutely zero controller or any other input setup apart from default, and just put the debug.log and it works
Potentially my version too if that's important? I'm on 2020.3.29f1 which is probably older than this controller as well if that matters
i doubt it matters, especially that for me it printed just Xbox one which my controller is a series s one
Fair enough, I'll keep trying I guess
try just disconnecting and connecting the controller with the project open maybe?
are you using bluetooth or a wired connection could matter also
Its bluetooth
can you try with a cable if you have one?
that would probably fix the issue i think
Connecting the joystick would normally say its type right? Unity just seems to recognise it as an empty string
yeah try with a cable
Ill see if I have a cable but I'm not sure I do
bluetooth works differently and recognizes it as different
Either way, thanks for all your help
Turns out I do have a cable, but it still returns empty unfortunately, probably just my controller
hmm idk then, thats the only thing i could think of to be the problem
That's alright, thanks for your help
May need to move on from the old input system haha
hey so I'm still learning unity and I'm trying to script basic character movement into unity, can someone tell me why my script is not showing up under components properly? I'm even following a video guide
what it should look like (from the video I'm following)
Do you have any compile errors and does the script name match the class name
what is the #if directive for mobile/touchscreen environment?
I keep getting this but idk if its related
other than that I don't have any errors popping up and yes the names match
are you trying to Run in vsc?
Definitely want to fix that right away. But it won't affect things in unity, just the vs code configuration
Show your whole console, including the whole border around it
None of this is the console
console
Just making sure the errors weren't hidden
Ok, then that was clearly a problem and now ig can compile
Add an ending simcolon to the end, or remove the ending one.
Your indenting is completely messed up, so it's hard to tell which.
Do one and if it doesn't work, then do the other
like the end of the entire script or the first part?
to the end
Of the whole script, yes
The error says line 81, which is where the error indeed is
Someone taht can explain me why its saying this error. I dont get it. Wym its missing a class attribute. its a interface wot.
public interface IBulletOnCollision
{
void OnTriggerEnter(Collider other);
}
public class EnemyBulletOnCollision : MonoBehaviour, IBulletOnCollision
{
private GameObject tempBullet;
public GunController gunController;
public int damage;
public void OnTriggerEnter(Collider other)
{
if (other.tag == "Player")
{
other.GetComponent<Player>().TakeDamage(damage);
Destroy(tempBullet);
}
//if on collision with a layer:
if (other.gameObject.layer == LayerMask.NameToLayer("Environment"))
{
Destroy(tempBullet);
gunController.DestroyBullet();
}
}
}
It looks like you've tried to add the IBulletOnCollision script to an object directly
you can't do that, you need to add in a MonoBehaviour that implements it
added that but it didn't do anything. I do think I see my issue so I'm going to redo the whole thing and hopefully should fix it
thanks for being patient with me lol
I'm so sorry. I said semicolon
I meant curly brace
} this thing
Oh fair. could be it. oops. Guess Ima scan through all the objects lul zzz
It is red, so I feel you need to remove it
I have a question: How do I fix the behavior of translucent polys that I've made so that they don't render as solid at certain distances?
2 and 3 are the same location, and 1 and 4 are the same location
Hey folks, building a very simple application for Meta Quest 3. I'm trying to implement a weighted laser for selection of objects (one that curves downward, like the photo). How can I implement this laser, and how can I map it to a Raycast hit? Thanks so much
i'd probably segment a bunch of raycasts and iterate over them until one of them hits
hmm, I’m pretty new to this ive only used straight lasers and raycasts, is there any other advice you got?
like how could I approach doing what you said lol
many videos on trajectory where they use linecasts to indicate where a projectile will hit
similar logics
gotttt it, any thoughts on rendering it?
linerenders
Is this even mildly helpful?
https://www.desmos.com/3d/bb5bf662af
My thought was if you have your character or the hand at the origin, you can plug in the math, c = height, b is arctan of the vertical angle, a is your gravity,, and alpha (the angle) would be rotation around the y axis
I mean . . . not really but I appreciate the thought haha
so you can test over the length of the ray (low t to high t)
oh ok
you need to solve for the collision point
can someone help me learn c# and remember?
yeah so basically you would solve for the ray to equal the collider, and take the lowest t value if there are multiple solutions
idk i've never done raycasting before tho
idk where to post this but i have a problem with my prefabs i am kinda new to gamedev but i created a prefab but it dont want to have a reference for maincamera and one game object idk why? i mean they are on the gameobject i cant get them on the prefab.
Prefabs can not reference scene objects
Hi all
I have multiple NPC in my game all having the same animator attached and same script...Right now when I am playing default animation it is playing the same for all NPC at once and they appear to be in sync with each other. What I want is to introduce random variation in the animation for each NPC
Like say for NPC 1 the first animation takes 1s for other it takes 1.5 sec (all randomly decided)
How do i proceed?
Are you using statics at all?
This is not normal behaviour
Or maybe I am misreading this. You aren't saying they all do the same animation at the same exact time right? Just that they all are too similar?
You may want to ask in #🏃┃animation
How can I MoveToward a position for 5 seconds
while at the same time the object is being pulled on by other methods
(i am trying to make procedural recoil)
doing the exact same animation at once
ditto
Then something is really messed up. Are you using statics?
i have no idea- just theres same animator attached to all the npc
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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.
!help
hey guys, im writing a style guide for a uni project, I was wondering if there is a term for when visual studio automatically adds namespaces at the top of the code that aren't actually being used (like when it autocompletes to the wrong thing)? Is that called intellisense or is it something different?