#💻┃code-beginner
1 messages · Page 96 of 1
yes you can. but interfaces are not components so you cannot add it to a gameobject
I am trying to add the PlayerMovement file but it keeps giving me can't add script
fix the rest of your compile errors
Unity and vs are clear of errors
you have zero errors in the unity console? not even unrelated ones?
can you add it via the Add Component menu? if not, try restarting the editor
then restart the editor
I did that too but it still wont let me
then there is some context you are not providing, such as whether this class is in some other assembly
is it that I made some of the scipts in vs community instead of making it in unity?
no
the assembly's are the same
That's how I do it almost 99% of the time
I think il just start a new project and rewrite everything
I guess, but there is a much less nuclear option here somewhere
Also, that makes me feel like you aren't using vwrsion control?
Can you show a screenshot of the error when you try to drag it in
Sorry, I meant the whole thing. Uncropped
are you sure you've restarted unity?
i exited out and reoponed the project in the hub
Hmmm. Try commenting out everything in the script, saving, compiling in unity, uncommenting, and compiling again
Just curious, but have you turned off domain reloading?
Then you probably haven't haha. Turning it off could cause this issue
an editor restart would have reloaded the domain though
I think it was off
I'm trying to assign a CanvasGroup to turn on and off a panel. The CanvasGroup works, but not sure where I went wrong in the code to get it to work. I'm following a Tutorial on an older version of Unity so I think that might be why, but not sure where it's wrong
Yeah that's what I was thinking too. No idea otherwise though
That is the default setting
be more specific about what exactly is not working
When I play the game I click the box and it turns the panel off because the default is off, but once I get to the point that I can afford the next panel it doesn't turn on or show available. So it doesn't update the interactable/alpha values.
where are you calling this method and what debugging have you done to ensure your conditions are evaluating to what you expect?
also it doesn't mark the StoreUnlocked as True. This is the only place I am using the CanvasGroup. I don't have it anywhere else in my code. I don't have any debugging for this as I'm still pretty new so I'm just working my way through a tutorial and reading and looking up as I go. I tried googling this, but didn't see much that could give me direction
is this a help channel
most channels are help channels. but you can use id:browse to find one that is relevant to your issue
thank you
Thanks @slender nymph I'll work through that.
im following this tutorial https://www.youtube.com/watch?v=rJqP5EesxLk&list=PLGUw8UNswJEOv8c5ZcoHarbON6mIEUFBC
i made this script after i turned my action map "default" into a class as seen in the first image. in the second image you can see my code for a input manager located in the scripts folder, and in the thrid image is my errors. what have i done wrong?
The first video in a series where we are creating a First Person game!
In this video we look at setting up our characters movement.
I've setup a Discord!!! and I would love to have you help me start up a friendly community where we can all help each other grow as game developers!
Discord invite link:
https://discord.gg/xgKpxhEyzZ
Can't wait t...
start by configuring your !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
• Other/None
ah
How long is everyone's project list? When you want to experiment with a new mechanic do you prefer to make a new game or do you prefer to test it within another game?
usually when i plan on something bigger i make a new project
do whatver i gotta do there
and then move it into my main project after it works
Gotcha
that is weird approach
works for me
just make new branch on git, and experiment there
Unless your projects are big, which may cause long reloading times, you can very easily just test something in the same project. You're probably just eating up storage space by doing this
I have a vehicle in my scene that randomly moves in all sorts of directions when the game starts
It is like some invisible ghost is moving it
The position keeps changing
does someone know how to make visible and invisible text button
like it says visible but when i click it it says invisible
I am trying to get a 3d cube to change colors when an option is selected on a dropdown box. This is the code for the scripts I have
using System.Collections.Generic;
using UnityEngine;
public class Dropdown : MonoBehaviour
{
public Material[] colors;
public GameObject cube;
public void DropDownOptions(int val)
{
cube.GetComponent<Renderer>().material = colors[val];
}
}
What am I missing?
Write a script that when button is clicked it replaces button's text?
void Update()
{
Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
mousePos.z = transform.position.z;
Vector2 direction = mousePos - transform.position;
float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
angle -= 90f;
rb.rotation = angle;//Quaternion.Euler(0, 0, angle);
float hInput = Input.GetAxisRaw("Horizontal");
float vInput = Input.GetAxisRaw("Vertical");
if (Mathf.Abs(hInput) > 0 || Mathf.Abs(vInput) > 0)
{
Vector2 direction2 = new Vector2(hInput, vInput).normalized;
Vector2 movement = direction2 * speed;
rb.velocity = movement;
rb.angularVelocity = 0f;
}
else
{
rb.velocity = Vector2.zero;
rb.angularVelocity = 0f;
}
}
is there anything that i did not optamize properly here?
I know fixed update is good for velocity but i also have it mixed with the rb.rotation so its not smooth without update.
i am lagging like crazy because of this and its updating so slowly someone help XD
its still colliding but its like its delayed collision and its updating the position in a clipping mannor if that makes sense?
update: fixed my problem. now i have a new problem.
so im gonna fix that
I don't understand the video. Can you explain what it is we're looking at? Seems to be teleporting if the rectangle object is supposed to be solid
so yeah
the rectangle is a tile map
has a tile map collider 2d
the player has a 2d cylinder2d collider
and for some reason my whole game is lagging like crazy to the point where its clipping through
i have no clue as to why its doing this. I was gone for 2 days and it started happening ;p
Is the game lagging or the character simply teleporting?
How do I get Unity to not resize my images upon load, keep the ratio the same as it was when it was uploaded?
This is the beginner coding channel, try #💻┃unity-talk
yeah sure thanks
@ivory bobcatfixed it haha it was just my pc 😭
i am so sad i gotta get a new pc this thing is about to die
hello, so I'm new to coding I just started yesterday and I followed brackeys fps controller system and all worked okay, sometime later I got this error saying that UnassignedReferenceException: The variable groundCheck of PlayerMoveScript has not been assigned. even though I did assign ground check (I think), so well here's the code, it all worked fine until I deleted something (outside of the code) and I started getting the error, it was just in the console because in game everything worked out well, here's the code (can't get more than this script cause Im on my phone rn out of my home) https://pastebin.com/ANakeWzg
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I rewrote the part that was conflicting and still nothing
You need to assign ground check from the inspector or through code etc
i did
cant rn since not on my home but I think I assigned it, maybe if I re do ground check it'll work
You'll need to wait till you're available to check to figure it out
alright
in case it was successfully assigned and it still doesn't work, any idea on what could fix it?
It's definitely not assigned. There may be another object with the component in the scene, if anything.
ok
One thing you can do is search in the hierarchy. You would type t:PlayerMoveScript and only objects with that component would show. It may show more than one, which might be the issue as Dalphat said.
There IS a missing reference somewhere
alr
is this the correct logic to check if a toggle has been turned off?
checkbox.onValueChanged.AddListener(delegate { CheckBox(checkbox); });
The main thing is to get a 3d cube to rotate 90 degrees while it is toggled on, but I am having difficulty in achieving that, I believe it is something to do with this part though im not 100 sure
That will call the CheckBox function whenever the Checkbox is changed, and it'll pass the new value as a parameter to that function
So that does work to check if the box has been toggled at any time?
It is more like it will tell you when it is changed. Not checking if it has been
But in essence, yes.
The event it fired when it happens
This is the function it is calling
{
isRotating = isCheckbox;
transform.Rotate(0f, 90f, 0);
}
Does this even work to have the cube rotate 90 degrees each second?
fun fact, that's not passing the value of the checkbox to the CheckBox method. it's passing whether or not the checkbox object is null 😉
Oh
you don't need to create a delegate there. just AddListener(CheckBox) should (theoretically) be enough
thats not what I need. I am wanting it to rotate a cube on its y-axis continuously while the toggle is on
that's also not what is happening. you'd be better off just checking the checkbox's value inside of Update and calling transform.Rotate there
so checkbox.AddListener(CheckBox(checkbox));
i need to change the names of variables now that I am reading this
checkbox.Addlistener(CheckBox) ?
the method added as a listener is only going to be called once for each change of the value. so this isn't going to work the way you want anyway. just do this #💻┃code-beginner message
Am I supposed to be able to click on the code-begginer thing?
yes, it's a link to a specific message. the same message where i told you to just check the checkbox's value in Update
Oh sorry
That worked. Thanks!
Question how do I teach my self code and not in like the basic way like the way for me to know many possible ways on what to do and how to approach some things while writing the code?
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
It depends on how your brain works though
How would I check the index value of a dropdown box?
Hey guys, so I am trying to do a ground check with a raycast, and my Debug is stating that my Player is constantly grounded
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float moveSpeed = 5f; // Adjust the speed as needed
public float jumpForce = 10f; // Adjust the jump force as needed
//private bool isGrounded;
private bool canJump;
private Rigidbody2D rb;
private bool isGrounded;
private void Start()
{
rb = GetComponent<Rigidbody2D>();
}
private void Update()
{
CheckGrounded();
MovePlayer();
}
private void MovePlayer()
{
// Get movement input using the new Input System
float horizontalInput = Input.GetAxis("Horizontal");
// Move the player horizontally
Vector2 movement = new Vector2(horizontalInput * moveSpeed * Time.deltaTime, 0f);
rb.position += movement;
// Jumping
if (isGrounded && canJump && Input.GetButtonDown("Jump"))
{
rb.velocity = new Vector2(rb.velocity.x, jumpForce);
canJump = false;
}
}
private void CheckGrounded()
{
//LayerMask layerMask = LayerMask.GetMask("Ground");
// Implement a simple check for grounding
isGrounded = Physics2D.Raycast(transform.position, Vector2.down, 1.2f);
Debug.DrawRay(transform.position, Vector2.down * 1.2f, Color.red);
if(isGrounded) {
Debug.Log("Grounded");
} else {
Debug.Log("Not Grounded");
}
// Reset canJump when grounded
if (isGrounded)
{
canJump = true;
}
}
}
Thanks 😁
Debug what your raycast is hitting to see why
I've figured it out I believe
My raycast is hitting the Player
because it originates in the center of the Players collider
is there a way I can have the raycast ignore the player collider? or would I have to somehow compare collider tags?
I dont do 2d so maybe others have better suggestions,
You can specify the layers to check in the raycast, maybe set a layer for the player then ignore it.
Or start the raycast down below the player then cast a short distance
Physic2D raycast has layermask Im pretty sure so just use that
hello can someon help me im having these weird white lines in my art
they only apeear in the game view though
{
}```
Is there a way to have an out variable in the first line like out Attack currentAttack?
which ever is declared in the forloop will fall out of scope when the loop ends
if for some reason you want to redefine the variable later on you can always just add your own scope like
void Method()
{
{
Attack currentAttack = new();
for (int i = 0; i < _attacks.Count; i++)
{
currentAttack.Value = 500;
}
AttackUnit(currentAttack);
}
Attack currentAttack = new();
}```
Not really a common practice but you can do that, though better just to redeclare instead of reinstantiating when possible. Actually probably doesn't matter since the compiler is probably smart enough.
ah nvm then i was trying to find a way to have less lines
Does anybody know any good unity game course that isn't using premade scripts?
What do you mean, premade as in stuff like cinemachine or like the person doesnt have a script written before making the video?
I mean premade componets like rigidbody
really it depends on the game you want to make
if you're reliant on speed, collision, and gravity then that's a lot more work
You arent gonna find what you're describing, 1 because it's a silly limitation and 2 because transform is a premade component so you immediately must use premade scripts.
everything in the engine is premade
Yeah I know that it's normal silly but I wanna learn c# too
and thought a game tutorial in unity would be a good way
so why cant you use "premade" components?
it's very possible to make a 2D platformer without rigidbodies if you do want to implement all that logic
or go half way and use unity's character controller
Then learn c# independently with console apps. Trying to do both will only make it harder, adding an extra constraint on top to not use as many premade scripts as possible will make it even harder
What are console apps?
I'm completely new to this, I came from gamemaker where you do everything form scratch so I'm not really familiar with this field
A console application, totally unrelated to unity. Everything will run in command prompt or terminal
There are online guides on how to learn as well like on w3schools. Realistically any of the top websites you see on google will be fine as well
usually a good idea. Make something not dependent through an update rendering loop like chess or checkers, or if you want to write one of those yourself that's possible too hahah
alright thanks for the help everyone!
https://www.w3schools.com/cs/index.php
this is the website i was referring to. i would say when you understand what a class is and how it can be used then you're probably fine to look into unity. This doesnt mean just use a class once, but actually make your own code and play around with it. You just really dont want to be guessing c# syntax while trying to learn unity, which is something that is done very often in this channel. Issues that should take 10 minutes end up taking the people literal hours.
I will try it out, thanks!
I want my enemy to smash the ground wait for a few seconds and then go back up but it doesn't work and I don't know why. Here is my code https://gdl.space/ifitumewud.cpp
Need help trying to toggle highbeams and lowbeams for vehicle spot light
`public class ToggleHeadLights : MonoBehaviour
{
float range;
Light lt;
float delay = 0f;
// Start is called before the first frame update
void Start()
{
lt = GetComponent<Light>();
range = lt.range;
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.F) && delay <= 0f) {
lt.range = range * 2;
delay = 0f;
delay += Time.deltaTime;
}
if (Input.GetKeyDown(KeyCode.F) && delay >= 3f) {
lt.range = range / 2;
delay = 3f;
delay -= Time.deltaTime;
}
}
}`
hello
Describe what in particular isn't working and what's working.
So basically if I run this code
I press F and the range of the spot light is multiplied by 2
I can read the code. What isn't working and what is though
Afterwards, if I try to do it again and nothing happens when it's supposed to divide it by 2
Basically back to how it was before
Try placing a log in the if statements
Likely delay plays a role in the unwanted behavior
I'm trying to have it so there's a delay between button inputs so that if you press "F", it doesn't try to switch the ranges back and forth in the same frame
Basically, I'm trying to get it to how a flashlight would normally work in any game, toggling on/off
If it's delay by 1 second
if delay is zero or less
do this
if delay is three or more
do that```
So if the delay is between the two values, what would happen?
Make a game from scratch?
Nothing right?
Aye
On initial start it's zero, so it'll do the first if statement when the button is pressed.
Thereafter, it'll not do anything anymore
Because delay would likely be a value greater than zero but less than three
It doesn't do anything. It's simply how long it took between this frame and last frame
I'm assuming you're wanting to increment delay in update and not exclusively in the if statements
Yeah
hi so i'm developing a mobile game and there's a bug where if i press 2 buttons simultaneously they would trigger their onclick events at the same time. how do i do it so that it will only trigger either the first button's or the second button's onclick event?
i made a code that would make the other buttons not interactable when a button is pressed but it only works when the button is released, so you can press multiple buttons at the same time and the script wouldnt work
you'd probably have a way easier time using a bool or enum to keep track of what your current mode is, high or low beams. The delay you have doesnt need to increment/decrement, this is really just one timer that counts to 3 (or down from 3 to 0). Id also just store the high and low value instead of doing the math, lets you customize it more later in inspector anyways. Based on your bool or enum, swap the values when input is given
What's the constraint? Is it limited to occur only once per game, time or?
I would simply place an early if statement to exit the function if the requirements aren't met
if(!first)
return;```
say i have 2 buttons, new game and load game, if i press the 2 at the same time then release them at the same time, the game bugs out and tries to create a new game then load a saved game simultaneously
Set flags/states to prohibit false positives such as selecting two buttons
any hints on how can i do that? pointers perhaps :>
if a button was pressed already
return;//ignore this function
...
buttonPressed = true;```
Where you'd reset the state once per frame or after completing/returning control to the menu
i would have to move functions like these to a script no?
You'd want to consider calling a function that would do other stuff and the wanted function that you've set.
so just one function with a flag and all the other functions that i want?
It's probably better to have a manager and simply fire a request for the event to occur. Where the manager would determine if the event should happen or not.
You'd then subscribe a single function for each button with a particular value to represent what has occurred ie an enum for main menu, info, new game or whatnot.
ahh i see, thank you
So I have a top down shooter I'm trying to make, and I'm confused on the scripting for it. It's a essentially a top down with a camera similar to Enter the Gungeon, with a toggleable FPS for ADS ( kind of like PUBG or COD Mobile). Anyway, I have the controls for that working pretty good, but I'm trying to get my character model to rotate with the FPS camera. I tried adding the same script from the FPS camera to the player, but that didn't seem to work. Is there a better way to do this? https://gdl.space/usidopipit.cpp
Nvm, I'm gonna have to rewrite the whole thing. 😅
Hi, i made a small game and i used onmousedown. it will work on phone too? or i need to use touchdown/up?
i personally find its best to use tmp buttons for mobile games
i have 2 buttons.. i use a lof of colliders
not really the place for it, but there's no other place to ask for me
I have a 112 KiB MySQL database with 2 tables: players and items
somehow it is using 1GB memory? this seems insane?
I cannot for the life of me figure this out. I'm following a tutorial for FPS movement and I have the EXACT same script as the guy I'm following but I'm getting the CS0103 "orientation does not exist in this context" error. https://gdl.space/egeqalafig.cpp
did you saved your script?
I did.
is orientation set?
the identifier name seems correct, by ctrl+f
Orientation is supposed to be a public variable so I can assign it after the fact. With the break in the script though, it won't update to allow me that.
check your spelling, simple spelling mistake
add a Debug.Log(orientation) right before setting moveDirection
you dont need to import particle system
Even if I added a Debug.Log, I can't test the game because I have compilation errors.
orientiation.right
!!!!!!!!!!!!!!!
Was just about to post that I fixed that. Thank you lol. Good eye.
set up your editor
You need to configure your !ide so you don't need a "good eye" to catch these things.
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
I've followed the guide for the manually installed Visual Studio but for some reason it still won't work for me. It's really picky with what it underlines.
are you running visual studio code or visual studio?
Where do I look to find out? I think it's just Visual Studio.
well one is named vs code or visual studio code
the other one is named visual studio
Oh okay. Yeah, just Visual Studio then.
should look like this
Exactly what it looks like.
then what's the issu setting it up?
it's like the most important thing you'll ever do lol
I'm not sure. I followed all of the steps in the setup guide Osteel posted, but I guess it's still not setup right? I've noticed this with other things on there as well. It doesn't underline spelling mistakes, and things like Vector3 are just normal type. I'll show a screenshot for reference.
I didn't have to do any setting up iirc
I just installed Unity first and then Visual Studio automatically set up correctly when installed
maybe try uninstalling & re-installing
screenshot your whole vs window
it only changes just in the end
first thing, is the Unity workflow installed in VS?
Are you talking about this?
IN VS
open the vs installer, check if the game dev with unity installed
I guess you did not follow the steps in the link
No, sorry. It had an update before I could double check. But yeah, I did that.
OK, so now the External Tools Window
Actually, I think it's fixed now. I didn't realize that updating was part of the process and skipped over it when I installed since I thought it was already up to date. Updating it just now actually fixed it. Thanks for the help!
Hey there quick update! I managed to "fix" this problem by adjusting the Obstacle Avoidance Settings. I turned the Quality from "High Quality" to "None" and it "works" now. But I don't know which further problems comes with that, so I'm "excited" so the what comes next...
I just wanted a floodfill alg, accidentally made a pathfinder 
it was even faster than my old pathfinder which I spent like a whole day to improve
So I want the camera to follow the player. I have set up an empty GameObject which it's the target of the camera (let's call it camTarget). The problem is that I can't understand where to place the camTarget in order to make the main camera move as the player does. Here is the code:
using UnityEngine;
public class Camera_Follow : MonoBehaviour
{
[SerializeField] public Transform target;
float pLerp = .02f;
float rLerp = .01f;
private void LateUpdate()
{
transform.position = Vector3.Lerp (transform.position, target.position, pLerp);
transform.rotation = Quaternion.Lerp(transform.rotation, target.rotation, rLerp);
}
}```
Both Lerp are wrong, the third argument (float value) should gradually go towards 1 over time
Here is the scene view. The cylinder is the actual player, and the capsule is the camera target.
Here you're setting the position and rotation to 2% and 1% of the way between the two values, respectively
If I were you I'd just use Cinemachine which has all that behavior ready and much more configurable
I have a toggle between 3rd and 1st person as a sort of ADS feature, but with my movement options it changes the rotation of my player in the 1st person mode ( intended) and I need to reset the players rotation when they go back in to 3rd person. What would I add to my script for that? I tried transform.Rotation a couple different ways but it kept returning errors. https://gdl.space/ucogacofad.cpp
Mhm I think it's time to implement Cinemachine yeah. It would save thousands of hours 😅
Nvm, figured it out.
Why does my coded camera boundary cause my ship to slide up/forward when my camera is tilted?
The sliding doesn't happen if I disable the tilting
how can we know without any context and code
So first of all, my virtual camera uses the following scripts to make it follow the player with some dampening, with boundaries to stop it from following after the camera hits it. The boundaries are in a fixed position from the starting point of the camera
The rotate script tilts the camera itself, but not the boundary
!code is required to see where the issue could be
📃 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.
One moment
This is the script for the camera follow: https://gdl.space/qiqosacehu.cs
And this is the script for camera rotate: https://gdl.space/awagajeley.cs
Finally, this is the code used to control the player, which is the ship, just in case you need it: https://gdl.space/ecidaqawaq.cs
If you get any clues or solutions out of these, do please let me know. I've been scratching my head with this problem alone for ages
How does one call two coroutines sequentially?
I have these lines of code, only first coroutine is being called
var enemy = collision.gameObject.GetComponent<Enemy>();
enemy.StartCoroutine(enemy.StumbleAnimation());
enemy.StopCoroutine(enemy.CatchUpToThePlayer());
that last line says Stop not Start
Yeah, it still doesnt work proper;y, everything is executed in one frame
indeed, to start the second after the first is finished, put the start it the end of the first
you can yield return other coroutines
IEnumerator A(){
yield return B();
}
public IEnumerator StumbleAnimation()
{
float speed = 0.001f;
float time = 0;
enemyAnim.SetBool("IsOutOfPlay",true);
// enemy stumbles and flies in the air
yield return new WaitForSeconds(0.5f);
// lies on the ground
while(time < 1)
{
transform.position = Vector3.Lerp(transform.position, outPoint.position, time);
time += Time.deltaTime * speed;
yield return null;
}
StartCoroutine(CatchUpToThePlayer());
}
public IEnumerator CatchUpToThePlayer()
{
float speed = 0.001f;
enemyAnim.SetBool("IsOutOfPlay", false);
// enemy cathced up to the player
float time = 0;
while (time < 1)
{
transform.position = Vector3.Lerp(outPoint.position, startRunPoint.position, time);
time += Time.deltaTime * speed;
yield return null;
}
}
yes
so, from the second coroutine i should iterate through the first one?
no
second one isnt called
after 5 sec nothing happens and enemy is freezed
Debug them
initially it was all one coroutine, but that second lerp part wasnt executed, so i though that might help, it didnt
so you have debug it and the while loop doesnt run?
and i think you doesnt reset the time so that it is still one before enter the while loop
he says they are one coroutine at beginning, maybe i misunderstood
How do I rotate the camera ingame? I am using Cinemachine
yeah it was all one, i reset the timer before second lerp but that lerp was never executed. Now I've debugged it, and the code never even reaches that second startCoroutine line.
Ah yes, I understand. The answer is google
program exits before reaching that line
Game terminates or coroutine ends?
public IEnumerator StumbleAnimation()
{
Debug.Log("First coroutine");
float speed = 0.001f;
float time = 0;
enemyAnim.SetBool("IsOutOfPlay",true);
// enemy stumbles and flies in the air
yield return new WaitForSeconds(0.5f);
// lies on the ground
while(time < 1)
{
transform.position = Vector3.Lerp(transform.position, outPoint.position, time);
time += Time.deltaTime * speed;
yield return null;
}
enemyAnim.SetBool("IsOutOfPlay", false);
// enemy cathced up to the player
time = 0;
while (time < 1)
{
transform.position = Vector3.Lerp(outPoint.position, startRunPoint.position, time);
time += Time.deltaTime * speed;
yield return null;
}
}
coroutine ends
above you see the initial variant
i thought that too, but even now i try that initall variant out and it doesnt work. Enemy is stuck on the stumble animation
so, i guess the line where i set bool to false is never reached
Why guess? Place a log after and see if it prints
Also, if time scale is zero, it'll never complete the first loop
because in animator enemy is in stumble animation and IsOutOfPlay is true
That doesn't mean that the function did not finish
It simply means that you did not get what you were expecting
You need to place a few logs or use the debugger to see what's actually occurring
If anyone else else is free, pls take a look at my issue and tell me what's wrong
If you don't provide information, people will continue to ignore the post. #854851968446365696 for how to post questions.
well, i've placed .log before setting IsOutOfPlay to false, as expected, nothing shows up
Maybe the loop never completes?
But I have provided the code below it
What more do you need?
ok, i went through the code, after going through the loop couple of times i get this sccreen
its from LateUpdate(), so... my guess loop does end
I asked this question a few time but got busy with other things so i could not reply but I have a script i want to put on a button so when i press it the the next key pressed is set as the key for whatever action i set for it i.e. movement, dashing, ect. So i have an Input action reference i have on the button script that i can set the action i want to rebind to in and it properly updates the way i want it to (when i press the button then press a key it changes the action to the new key). Then I need to update the input action which holds the data for all the controls in the MenuManager so the code in the attached image is supposed to do that but as you can see in the logs it never changes the controls button.
Im back to two coroutine, now at least the both play out but way too fast, how do i make sure second will play only after the first one done executing?
public IEnumerator StumbleAnimation()
{
Debug.Log("First part");
float speed = 0.001f;
float time = 0;
enemyAnim.SetBool("IsOutOfPlay",true);
// enemy stumbles and flies in the air
yield return new WaitForSeconds(0.5f);
// lies on the ground
while(time < 1)
{
transform.position = Vector3.Lerp(transform.position, outPoint.position, time);
time += Time.deltaTime * speed;
yield return null;
}
}
public IEnumerator CatchUpToThePlayer()
{
Debug.Log("Second coroutine");
float speed = 0.001f;
enemyAnim.SetBool("IsOutOfPlay", false);
// enemy cathced up to the player
float time = 0;
while (time < 1)
{
transform.position = Vector3.Lerp(outPoint.position, startRunPoint.position, time);
time += Time.deltaTime * speed;
yield return null;
}
}
Does anyone know how to create a camera shake when walking in 2d using cinemachine?
afaik there is a thing called cinemachine impulse
Call it at the end of the first coroutine. But that's exactly the same as having one coroutine. Speed 0.001 means that the first coroutine takes almost 17 minutes to finish, I'm guessing that's what's causing it to look like it's not working
Is there a proper way to check if 2D character is grounded?
And if counting colliders is best implementation, can someone tell how to ignore cinemachine confiner?
Likely it's related to your ship movement and not just camera positioning.
i specifically made speed that little because enemy was just flying all around
Ok, but it's still 17 minutes
The enemy flying around is a separate issue, solve it separately
The ship movement is independent from the camera's orientation, using transform.localPosition in the LocalMove function
I'm not certain what you were trying to illustrate but the left screen shows that the camera bounds was working properly.
The bounds DO work as intended. It is possible that the issue lies within the camera's clamping
What's the unwanted behavior? Did you intentionally elevate the ship or was that something due to the camera?
I want the ship's position to stay the same when it is hitting against the clamped position
But due to a strange interaction with the camera's bounds and the world to viewport clamp, my ship is sliding up/forward
Show your ship moment script please
If your ship is moving in an abnormal behavior, you'll need to provide that.
The ship's movement lies in this code, specifically in the LocalMove function
So to narrow this problem down, try commenting out the clamp position function
Does the ship still move abnormally?
If not, then it's solely due to these linescs void ClampPosition() { Vector3 pos = Camera.main.WorldToViewportPoint(transform.position); if (pos.x < 0.15f || pos.x > 0.85f || pos.y < 0.15f || pos.y > 0.85f) { pos.x = Mathf.Clamp(pos.x, 0.15f, 0.85f); pos.y = Mathf.Clamp(pos.y, 0.15f, 0.85f); transform.position = Camera.main.ViewportToWorldPoint(pos); } }
Where view port to world point is modifying the position of the ship.
Without clamping, the ship can simply go offscreen, which I don't want either
But it does not behave in an unexpected way?
Does it continue to slide up? (assuming you did not explicitly slide up in the original clip)
No
So, likely the repositioning of the player using view port causes an increase in y position and the camera to follow the player in y position.
z position too if the ship is hitting the top and bottom clamp
Yeah. Figure out why the conversion is producing those unwanted values.
why is my calculated distance dash is always double the actual distance dashed
https://gdl.space/royizixide.cs
I NEED ACTUAL HELP
why is Coroutine always buggy
how do i make an object eventually move to x axis =0?
if(column == Column.Right && transform.position.x<3.5f)
{
Vector3 horizontalMove = transform.right * speed * Time.fixedDeltaTime * horizontalMultiplier;
rb.MovePosition(rb.position + forwardMove + horizontalMove);
}
else if (column == Column.Left && transform.position.x > -3.5f)
{
Vector3 horizontalMove = -transform.right * speed * Time.fixedDeltaTime * horizontalMultiplier;
rb.MovePosition(rb.position + forwardMove + horizontalMove);
}
else if (column == Column.Middle && transform.position.x != 0f)
{
// Vector3 horizontalMove = -transform.right * speed * Time.fixedDeltaTime * horizontalMultiplier;
rb.MovePosition(rb.position + forwardMove + horizontalMove);
}```
the above code keeps moving the object from 3 different lanes where -3.5 is left, 3.5 is right and 0 is middle
but i don't know how to do the middle one
Maybe show people the logs as well
Specifically the position logs
how do I paste the logs here
I wonder... what if I only set the clamp values at Start or Awake?
Snap an image of the console logs from unity editor
Nope, it doesn't work
if right
if less than zero
go to zero
else if less then 3.5
go to 3.5
if left
if greater than zero
go to zero
else if greater than -3.5
go to -3.5```
Hi. Does anyone know how can I set special characters to a text mesh pro UGUI component please? because nothing seems to appear, or it just shows up as a square😅
You need a font that supports these special characters. Boxes are displayed as placeholders for glyphs (font character symbols) that are "not supported"
The thing is that I searched for a font that in theory supports those characters
It's an import issue then, you need to tell the TMP Font Asset Importer to generate glyphs for these special characters
I think it does that by default, so check the import settings
does anyone know how to get a 2d top down movement/attacking similar to cult of the lamb? I want to have animations in 4-8 directions for walking and attacking, but I also want to only face the mouse when I attack
yeah it isn't creating those special characters. I don't know where that option is 😦
It's when you import the font and create a Font Asset from it, it opens a window with import settings
great now my slime doesn't even dash anymore
I tried this code c# else if (column == Column.Middle && transform.position.x !=middle) { Vector3 horizontalMove=Vector3.zero; if (transform.position.x > middle) { horizontalMove = -transform.right * speed * Time.fixedDeltaTime; } else if (transform.position.x < middle) { horizontalMove = transform.right * speed * Time.fixedDeltaTime; } rb.MovePosition(rb.position + forwardMove + horizontalMove); }
I noticed that the object keeps trying to reach 0 but it never does, it's switching between different values (0.2,0.3...) i noticed this with the left and right logic too but it's not noticable since the check has >= and not strictly =. is there a way to solve this so it is guaranteed to reach the exact value, or do i have to use something like checking if it's in a value range?
in theory this font should support these, and I imported with those settings, I don't know which setting is wrong sorry
The "Character Set" option
what should it be on?
It's in Extended ASCII mode which is still a small character set compared to Unicode or even UTF8 which can have thousends of glyphs
and what do I enter in the select font asset😅
None, as the message above says
someone pretty please
I'm sure a lot of people can.
It's only if you need to retrieve the ranges from another Font Asset, useful if you add the same characters from another font
Math f min and max.
so then it should just be click GenerateFontAtlas and it should already accept those special characters...?
Yes, it will scan the whole font file
yes its verry common.
What have you tried?
doubt anyone is gonna lay out a step by step online
didn't detect anything😅
can you please give an example
i just can’t find any tutorials for it
all the ones i find make the player always look at the cursor
currently i'm trying to snap the player if the position is between 0.5 and -0.5
probably because you're looking for something too specific instead of just combine stuff together to get end result u want
You need to specify ranges in that big text box. From the website where you got the font, these should be written somewhere
alright
You'd want zero to be the max when greater than middle to not be lower than zero and min when less than zero to not be greater than zero.
https://docs.unity3d.com/ScriptReference/Mathf.Max.html
https://docs.unity3d.com/ScriptReference/Mathf.Min.html @prisma blaze
the find the regular 8 sprite/movement first, then you can look for the mouse attacks vids and combine the two, rinse and repeat.
it is from google fonts (https://fonts.google.com/specimen/Zen+Kaku+Gothic+New?preview.text=MWP2 指事字 á jet € %3F _ º ° ASDUV привет&sort=popularity&query=kaku¬o.query=kaku to be exact)
I don't really know what I'm looking for, like what are "ranges" in this case?
i’ve got 4 directional sprites right now, but is there a way to also make it so the attack goes right to the mouse, and does the closest attack anumation?
float value = Mathf.Max(..., 0f);//Value cannot be lower than zero```
I've attempted to do what was said here. (Not sure if it's right?)
But here's what it looks like and my script.
But my character doesn't seem to get parented when I touch it?
ofc there are plenty of ways to do something.
i still don't get the idea. if transform.position.x==0.3, how do i use Max/Min to make it 0?
never comepare floats with ==
just ==
The Movement I got is "static". For example if I look backwards, and press W, It will go in the opposite direction instead of moving where the camera looks at. This is the current code.
using UnityEngine;
public class Movement : MonoBehaviour
{
public CharacterController controller;
public float movementSpeed = 50f;
// Update is called once per frame
void Update()
{
float inputX = Input.GetAxisRaw("Horizontal");
float inputY = Input.GetAxisRaw("Vertical");
Vector3 direction = new Vector3(inputX, 0f, inputY).normalized;
if (direction.magnitude >= 0.1f)
{
controller.Move((direction * movementSpeed * Time.deltaTime)*2);
}
}
}
Each character has an index (its position) in the character set. They're not available from the website so you can first attempt to just import the Latin characters that would be in the range 0000-007f, and if it works you can extend to the full Unicode range 0000-ffff. Note that this will probably take a moment to generate, and will probably yield a huge font asset file
My assumption is that the value oscillates between greater than and less than zero but not ever zero when approaching zero due to the values never being zero.
why would it go where the camera is at?
ohhh okay. Thank you so much 😄
yes that's what happens
nowhere does it say so @rustic cave
If you look backwards and press W it goes in the opposite direction
look direction is irrelevant in the code you sent. its only based on your inputs
if you wanna move where you look you need transform.forward
It's a movement related issue
and how do I know I've included all characters?😅
maybe you don't understand what your own code does?
By testing the font in Unity
code doesn't magically do things you don't program it to do @rustic cave
No. I mean you misunderstood what I was trying to say, and please don't @, use reply instead
ok maybe explain it better then ? all you said was it doesn't move where its looking, and I said there is nowhere in the code to tell it t do that
like tight now I have this text, and it shows that, and I've tried those settings. Does that mean I still have to increase the number or that I've gone too far and so it broke?
People do @ when they forgot to do reply. You can't do a retroactive reply after.
What difference does it make anyway?
fr
I'll send you a video
What kind of alphabet is that, Hiragana?
From Google Fonts there's a tab called "Glyphs" where it regroups them under categories.
chinese
It does sound like nav is spot on with the issue and solution. Only other thing I would add is that you need to rotate the object, which you don't seem to do at all right now
i've spent hours just fiddling around with the transitions trying to fix it
public IEnumerator StumbleAnimation()
{
float timeElapsed = 0;
enemyAnim.SetBool("IsOutOfPlay", true);
Debug.Log("Bool set");
// pull enemy out of screen
while(timeElapsed > 1)
{
transform.position = Vector3.Lerp(startRunPoint.position, outPoint.position,
timeElapsed);
timeElapsed += Time.deltaTime;
yield return null;
}
Debug.Log("Pulled back");
enemyAnim.SetBool("IsOutOfPlay", false);
Debug.Log("Bool set false");
timeElapsed = 0;
// get enemy back on sceen
while (timeElapsed > 1)
{
transform.position = Vector3.Lerp(outPoint.position, startRunPoint.position,
timeElapsed);
timeElapsed += Time.deltaTime;
yield return null;
}
Debug.Log("Enemy is back on screen");
}
Alright, some of the characters I see in your screenshot are definitely Japanese, so you can try with the Japanese Unicode range first to see if they're included:
3040-309F
And for the other ranges, nothing better than the official Unicode website
how do i make coroutines not play out at the same time?
all debug are displayed so, everything works, exept it all happens in one frame
Have a bool condition. Set it false inside the coroutine when it starts, set it true when it ends
with that range, nothing appears😅
@bold nova
if (!isRunning) StartCoroutine(myRoutine);
IEnumerator myRoutine()
{
isRunning = true;
//do stuff
isRunnimg = false;
}
hi everyone i was just wondering if yall could help me i was follwing a tutorial and i was trying to get the pause menu to work i have the start menu to work but whenever i press escape nothing happens only my mouse appears ?
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.SceneManagement;
public class PauseMenu : MonoBehaviour {
public static bool GameIsPaused = false;
public GameObject pauseMenuUI;
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
if (GameIsPaused)
{
Resume();
} else
{
Pause();
}
}
}
public void Resume ()
{
pauseMenuUI.SetActive(false);
Time.timeScale = 1f;
GameIsPaused = false;
}
void Pause()
{
pauseMenuUI.SetActive(true);
Time.timeScale = 0f;
GameIsPaused = true;
}
public void LoadMenu()
{
Time.timeScale = 1f;
SceneManager.LoadScene("Menu");
}
public void QuitGame()
{
Debug.Log("Quiting...");
Application.Quit();
}
}
Looks like you need to use transform.forward of the camera
Or rotate the object along with the camera
Can you try directly in C#? Like .text = "\u3041", so we can see if it's what you copy-pasted, or if it's the font
inside update method?
What inside Update method?
Why the camera and not the movement?
Because that is the issue
The camera rotates, and that rotation is never used
well, the coroutine is supposed to be called when players and enemy colliders collider and player isRolling == true. I dont understant how condition can help
it was the copy pasted :/
Show code at this point
But simply, a condition will stop more coroutines from starting
It will make it so only one runs at a time
!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.
but now how can I know which unicodes to include? because I don't know which languajes are actually in the file
Coroutine in enemy's script
public IEnumerator StumbleAnimation()
{
float timeElapsed = 0;
enemyAnim.SetBool("IsOutOfPlay", true);
Debug.Log("Bool set");
// pull enemy out of screen
while(timeElapsed > 1)
{
transform.position = Vector3.Lerp(startRunPoint.position, outPoint.position,
timeElapsed);
timeElapsed += Time.deltaTime;
yield return null;
}
Debug.Log("Pulled back");
enemyAnim.SetBool("IsOutOfPlay", false);
Debug.Log("Bool set false");
timeElapsed = 0;
// get enemy back on sceen
while (timeElapsed > 1)
{
transform.position = Vector3.Lerp(outPoint.position, startRunPoint.position,
timeElapsed);
timeElapsed += Time.deltaTime;
yield return null;
}
Debug.Log("Enemy is back on screen");
}
playerControllerScript
private void OnTriggerStay2D(Collider2D collision)
{
if (collision.gameObject.CompareTag("Enemy") && isRolling)
{
var enemy = collision.gameObject.GetComponent<Enemy>();
enemy.StartCoroutine(enemy.StumbleAnimation());
}
}
Okay for completeness' sake, can you copy one that is like this (if you can find one) from your TMP input box, or from wherever you took them, and try to get its index in the charset?
Debug.Log(((int)'YOUR CHARACTER HERE').ToString("X4"));
I would not call the coroutine directly on the enemy
I would call a public method that in turn starts the coroutine.
That public method checks the bool to see if it's already running
If it IS running, don't start the coroutine
like the one you told me or one of the ones I copied from the google fonts?
like this for example?
Yeah looks good to me
sorry for pinging u later, but how would i combine them? I only want the player to face the mouse when attacking
there is a way to check if a navmesh agente is conencted to a navmesh?
Okay so that's the index of that character in the charset. Not sure how to deal with this because it's not in the range that was generated for this font
4EBA is from "CJK Unified Ideographs" and is range 4E00-9FFF which is a huge range
The Unicode PDF explaining it is 533 pages, gives you an idea on how much characters are in this lol
unfortunatelly no difference, mate. I get debug.log messages, but no actuall animation
sorry for my ignorance, but do korean and japanese use the same as chinese characters?
thx, im tryign to make a drag and drop of units from a lits to a scene, i want teh drag event loop to try to snap the unit into the navmesh, if its on a navmesh when the drag stop it puts on hte unit field
not sure if this is the best way to do this
Not at all, but they might fall within the same Unicode range. You'll have to see from the Unicode website, the home page groups the glyphs by regions
so like for example in order to add "á", what region do I have to add? And to add a region, do I have to add it like this with comas?
The à will be your regular Latin character range. As for the separator good question, try it and see
I was only helping run only one coroutine at a time (making it sequential). Nothing to do with anymation. If you did what I said, it will make it sequential.
If it's not working as you want after that, then it is a different issue
this range I'm guessing then? (got it from the site you sent)
That's the basic, you'll have to have at least the Supplement to get the accented characters. Each PDF has a table with the characters
okay so, this range has the 'á', but when I enter that range, nothing appears😅 . I'm going to check if that's just the font now
it def has it
how can i avoid this deformation when i parent an object to another?
need some help
How come mine is not showing color nor giving me options to chose from?
Only use uniform scaling on objects that have children in the hierarchy
!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
• Other/None
1:1:1
alr
Scale has to be x1, y1, z1
Or x2, y2, z2
Or so on
If you need to scale something make it a leaf node without children
ok
already fully updated
That is only one step
There are more
Thats only one of many steps you need to follow
oh sorry mbmb
got the snaping into the navmesh by enabling and disabling the navmesh agent while it dotn have navmesh connected, but i cant drag the unit out of it without doign the same thing
anyone have a suggestion?
mayeb there is a wy to cehck how far the cursor need to be from the attachzone?
im randomly getting this thing where my typing bar turns into a box and it deletes stuff
Then stop hitting the Insert key on your keyboard
what is the insert key
The one with Insert written on it?
Should method names be in pascal-case?
They can be in any case you like, it's much more important to be consistent
The C# coding conventions are pinned to #archived-code-general if you want a good place to start
How to make list like this? I mean I forgot how it is called.
Slider is a thing that slide and how is it called?
Not a list because list looks diffrent
is it possible to make something happen becasue of an animation
like can I turn on a collider2D when an animation happens
if so how
Use an animation event
how would i do that
Google Unity animation events
Its notes
It doesnt count to your code
@gentle moat its an example of my script
That has //
alr thats waht i was thinking
Comments
how do i send code like that?
you don't. you use the bot's message below to send !code correctly
📃 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.
ah
You can just bring C# file from unity to chat
But its reccomendet to use this simple command
Because some of the ppl here that can help you are on phones and on phones they cant see the file of code so u would have to use this command to show them your code
https://gdl.space/osoxoviviv.cs can anyone tell me what I would put in the _______ to have an animation trigger that turns the collider off?
Update
you can give your methods whatever name you would like
how do i do that tho?
except that because that wouldn't make any sense here
i'd suggest you take some very basics programming and unity tutorials
you cannot get help with this knowledge
i started unity like 3 days ago 😭
because you just dont understand the help
You put it in Update and then u use if method
You can turn on/off colliders in AnimationEvents
would be much easier with more control
I reccomend you to learn basic C# first. I reccomend you the YouTube CodeBro channel with 4 hours C# tutorial. Its one of the best free tutorials and from there u would be able to make simple games belive me
alr
ohhhh i was doing that before and made new animations and forgot to add them back 😭
ty
im so dumb
How do I get the brackets to format on the same line with Shift + Alt + F? back den I was using omnisharp but how do I do that with the new system of the C# Dev Kit?
eg, I want it to format as such
public class Player : MonoBehaviour {
// Start is called before the first frame update
void Start() {
if (true) {
//etc
}
// Update is called once per frame
void Update() {
}
}
probably in the c# dev kit settings?
Couldn't find it
might need to modify the settings.json
Hey yall i need some help please.
Im trying to make a lives system in my game. Where the player has 5 lives, if they lose a life they need to wait say 20min to restore that life.
I got the code working for it.
But if i add my timer it will countdown the time from 120seconds (i made it 2min for testing) but it will count down super fast and the go into negative numbers when my debug shows i have only waited say 30sec.
Also my lives text doesnt want to display my current lives.
I have referenced both my texts.
I will add my code. Instead of using 5 seconds to test im using 2 minutes.
Any help would be appreciated please.
!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.
i know this might be a dumb question but i forgor, how can i make ads (aim down sights) make less recoil? i have floatsabout recoil like recoilx, recoily and recoilz, so what i need to know is, how do i decrease one number of a float when i hold left click? and get it back to the normal when not holding left click
You can multiply the value with something less than 1 to decrease the recoil
alr and how do i get it back to normal?
Don't multiply anymore
alr
The initial recoil value does not change, you just apply a multiplier to it. Or use two distinct recoil variables
ok
so its something like, adsrecoil = 5 and recoil = 10
when holding right click recoil * adsrecoil
You're mixing both systems right now
Either:
- Use two variables and don't multiply
- Use a multiplier
alright
Is there paranthesis placement correct here?
direction * (_moveSpeed * Time.deltaTime)```
yes
It adds modifiers to stats but modifiers dont change anything
Hey, guys! I want to create in my game movement before starting playing the game with my controls what I mean is I want to move my character horizontally to a certain direction and when it arrives in that direction then the game starts with me controlling that player. Can I make that somehow?
Sure.
Disable your player controller
Move X over time
Enable your player controller
Or just emulate the input inside the player controller while ignoring inputs, which would be even better, as it would use the right animations etc automatically
@tough lagoon Can you explain it and break it down to help me understand what I am supposed to do?
disable/enabling player controller easily found on google. Move X over time = change the transform in the update method using the gameobject.transform, time.deltatime, a speed per deltatime and direction
I know how to disable and enable player controller. I am just confused of that he said with move x over time what is that?
so if the speed is 5 m/s and your deltatime is 0.1s it's moving 0.5 along the X axis per time unit
It might not look perfect at first but it's a start. I dont know how exactly to make it look perfect either but if the position update are quick enough it will look smooth regardless
So, in that way you said player will not interact for that time with the character and when character reach that destination I will be able controlling the player?
you'd check if you are inside of pre-placed shape to know you reached the destination
make sure it's big enough for the character shape that is how Id do it personally (aka a trigger shape) since unity has many way to check if something is inside something. But my unity is very rusty I just came back from unity 5 - 2 days ago so hopefully someone can help with code specifics
You also want to wait just a little bit once the character is in the shape to return control otherwise it feels weird to the player because they have no hint of knowing / they might be confused if they can control it or not
with a slight delay like 1-3s it's clearer they can now move the character
can someone take a look at my thread?
https://discord.com/channels/489222168727519232/1183504205126848603
not sure if this is a code problem, but my spotlight for my flashlight works fine when pointed at the ceiling or floor
but when at a wall
if the light ever touches it the whole wall becomes lit for a bit
Sounds like it is vertex lit, maybe hitting the limit for pixel lights
Not a code problem in any way
Might be a question for #archived-lighting maybe
When I try to drag my game object prefab into my editor and assign it to a variable I get an error saying "Type Mismatch". I double checked I used the correct version of "GameObject" because it is in the scene but for some reason I am still getting this error. Anyone know how to fix this (I'm trying to drag "Player Goal" btw).
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
You cannot reference scene objects in the inspector for a prefab
alr so idk whats happening, but when i put a negative value, and after i stop holding the left click, the negative value goes to a positive value, not sure what can be making this error, my text is here
use one of the !code links
📃 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
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
which value are you talking about, its hard to tell from the video
hold up
recoilX and anything that has to be with the x axis
everything else is ok
ive been struggling with it for the past hour or something
well recoilX and removeRecoilx only changes when you change it in inspector, so i assume you're talking about ADSrecoilX
the only thing i see is that you assign it 10, but then the recoilX is -10. removeRecoilx is 5. So you can probably tell how -10 -5 becomes -15
I'm kinda confused I went to their page and it says everything is up to date and stuff how do I actually get little red underlines in my code so I know if something is wrong through visual studios?
yeah but not sure if i explained the right way
for some reason, positive and negative make the gun go down, but positive shoudl make it go up
and im modifying that on recoilX
did you look at the bot links you were shown #💻┃code-beginner message
it was linked for a reason
yea I did, I just wasn't quite sure what it wanted me to do because all it seemed to want me to do was check for updates and stuff which I did
i think this might be the line thats making problems public void RecoilFire()
{
targetRotation += new Vector3(recoilX * ADSrecoilX, UnityEngine.Random.Range(-recoilY * ADSrecoilY, recoilY * ADSrecoilY), UnityEngine.Random.Range(recoilZ * ADSrecoilZ, recoilZ * ADSrecoilZ));
}
use debug.log to print out what the targetRotation is. i assume you're getting some weird behaviour because you are multiplying recoilX * ADSrecoilX in RecoilFire()
what do you mean with printing out what it is, like just putting debug.log("insert text")?
sorry for my ignorance, im practically new since i started coding 2 days ago
did you click the right link for what IDE you're using? looks like vscode, i clicked the vscode link, there is more than just updating
instead of a string, print out the actual vector so you can see what it is
that way you can understand what the values actually are rather than "should be up, should be down"
ok
you can also use Debug.DrawRay or DrawLine to visualize your vectors
yea thanks my brain didn't make the connection that VS stands for visual studios sorry about that 💀
ill try
something like ths?
I think you just dont need to multiply recoilX * ADSrecoilX here, because it doesnt really make sense. Both seem to be their own value for how they affect rotation, so you should probably be using one or the other. When both are negative, they make a positive value. When both are positive they make a positive value.
yea
ooooooh alr
so ill just leavei t like that
ill send the debug log hold on
holy crap it fixed
thanks dude
you saved my mental sanity
ive been here on my pc the entire day trying to fix it 💀
you probably want it to choose a value based on if you are ADS'ing or not, but i dont know where that logic is being done
it doesnt seem like ADSRecoil is even used
yea so the ADSrecoil was used to mark what recoil i had rn, first photo is without aiming, second is with aiming
but it was honestly useless
oh then you probably want to use ADSrecoilX instead of recoilX since thats your affected value
same goes for the rest of the equation
now it works
alr
test it with exaggerated values, like 45 as your removeRecoil
right now, when you ADS, it doesnt have anymore/less recoil
yea ik
How do I know if my IDE is configured or not
because I thought I got it but when I write something wrong there is no red underline
Then it's not.
You'll also get syntax highlighting and autocomplete suggestions
!collab
We do not accept job or collab posts on discord.
Please use the forums:
• Commercial Job Seeking
• Commercial Job Offering
• Non Commercial Collaboration
How can I make a parameter in a function optional?
I tried just using "optional" (using my knowledge with unrealscript), but that didn't work
You can give it a default value so that you skip supplying it as an argument when making the function call.
Ah ok, so it just needs a default value
I wonder if optional in unrealscript just did that for me
Like just look at the type and then set it to the usual default if not supplied with a value
not sure about unreal myself, but in c# i assume the equivalent would just be
public void SomeMethod(int a = default) {}
it would be 0 in this case
!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.
Have you checked that you only trigger the audio to play once?
How do I go about checking?
Debugger or logging
anyone know why this happens?
https://hastebin.skyra.pw/olavuyacih.java
its the DrawFieldOfViewLines function
How do I log that? Debug.Log(audioSource.PlayOneShot(appleClip));?
Debug.Log("Played clip");
reset the read input after you call the audio?
it'll only do it once
after you call the audio do readInput.currentWord == "";
Ah I didn't realise there was code, yeah, you're playing it continuously
So the issue is as I suspect it's play it over and over again
How do I get it to only play once?
i just told you
It would make more sense if you weren't calling this function repeatedly in Update
and instead called it when the input changed or was submitted
Right
do i have to multiply something with visionPosition.rotation?
I'm barely starting to make Enemy Behavior on 2D Unity. I see people using something called a Navmesh and am wondering if I should use it as a begginer. What should I do? Also will it allow me to make a enemy AI that will have pathfinding and dodge getting blocked by environment?
It'll give you the very basis of creating some enemy AI, or player movement if you prefer controlling through pathing. Worthwhile to read up on it
Okay, I'll do it. Thank you so much!
@timber tide Forgot to ask if there is a official Navmesh download. I don't want to accidently download a virus. If you know one that would be very helpful 🙂
I think it's included with built-in, but urp you need to get the package
well, the newer urp versions since they've updated it a bit as of recent
It is. Thank you. I was going to download from git hub, but it is included with the URP Version.
hi im trying to have both a spawn and this top-down movement work at the same time. but everytime it just makes my player stand still
start by configuring your !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
• Other/None
after completing that, go through this https://unity.huh.how/runtime-exceptions/nullreferenceexception
🤔 you've been told at least twice before to configure your IDE, why not just do it
Is Navmesh plus a different package? I see other people using it on 2D and not using the that is inside Unity Register
how do i make it keep the same shape no matter what the rotation is?
If rotating it confuses you, use Handles.matrix to rotate the overall thing
whats that
It's a git repo you can download through the package manager
i did i configure my IDE
not according to your screenshots
Anybody have advise for the best way to preventing the player from being able to jump through walls and climb through jump spamming? This seems to be a common issue online but none of the fixes seem to be working.. Any advise would be greatly appriciated!
So then why did you temporarily un-configure it solely for the purposes of taking a screenshot?
I don't think it is, they have different components. Such as Navmesh Modifier Tilemap
Yes, I'm aware. It's a third party git repo you can download through the package manager.
Do you think I should download that version instead of the package one?
There is no built in package one
You can use the package manager to download git repos.
I promise i didn't mean to, i thought it was still configured, im sorry
Are you talking about the Navmesh Plus isn't a built in one or the Navmesh Package?
If it was configured you would be getting full autocomplete, error highlighting, and it would say the assembly name instead of Miscellaneous Files in the top left
navmesh plus is to be used with the built in navmesh stuff
If I am understanding: The Navmesh Package in Unity Register, is able to be used with Navmesh Plus which is availiable with Git Hub?
Navmesh Package is Unity's navmesh system. Navmesh Plus is a third party repo that extends the built in system with additional functionality.
So you need both
That makes sense, thanks for clearing it up!
Ah, I'm having significant difficulty with my decision tree; it keeps returning the same result and I don't know how to fix it.
I'm making a cardgame AI that's supposed to return up to three possible different results, but I keep getting one result over and over. Could someone please take a look at my code and tell me where I screwed up?
A tool for sharing your source code with the world!
Quick question if anybody knows the answer.
I have a build file that has audio in it, I am following along with one of the tutorials and when I build and run the project the audio works but in the Scene and game views it doesn't, even when I press play and everything.
I have attached images showing that I am not muted and that it is not volume 0 as well.
Any help would be greatly appreciated!
Edit: Apparently the tutorial files didn't have an audio listener attached to the body of the model sooo
What do you see during debugging? Is the selectedValue different every time? Add a debug where you return the candidate as well.
Got it, main issue is that the debug is a little jank right now as the ToString gives me some... cryptic-sounding compile-level names instead of the actual conditions, so I'll try to get you some info to narrow it down
This is what I'm getting back, though if I'm honest, I don't know how to get the ToString to be more useful than this
As you say though, I'll run through and check if Randomly chosen value is the same every time
You'll need to provide some names to your nodes, when you create them.
Need a bit help understanding NavMesh SetDestination(). How can I adjust the speed it goes to the target? ```agent.SetDestination(target.position);
Hmm, this time it returned 0... that seems a bit low, since if I'm getting 0s and 1s consistently, then that means totalweight isn't being added to
You can modify the agent speed property.
Hmm, it seems to be going into the revolt leaf each time, but the randomly chosen value is always 0 or 1, which is the values if totalweight is 0, meaning nothing's getting added to it right, even when it reaches a binary node pair that should be weighted
but what I'm confused about is how it's getting there to begin with because the only place that should consistently have a revolt leaf is if the hand value is exceptionally good, which isn't the case
Simple and Explained well! Thank you!
Is the best way of going about this adding a name variable (string) to the first of my three 'DecisionTreeNodes' class bits at the very top of the script? Sorry for the inexperience in this regard, like I said, this is a bit difficult for me.
Check what is getting added to the candidates list. If anything. I feel like there might be an issue with your conditions.
Right, I'm doublechecking as we speak.
Probably an issue with variable captures. Value types are probably staying the same as when you create the delegates.
(Sorry, this is taking longer than expected, I had to figure out what candidates were getting added by reworking the class a bit)
Ok, I think I figured it out actually, thank god
the gist of it was that the poorcheck seems bugged currently, and it always assumes the player is too poor to retreat, thus always returning the same result
it never even made it into the other nodes
hi, is there a way to store different scripts in the same variable.
i want different type of scripts to be stores in each variant of the scriptable object.
like a generic variable that accepts different classes maybe?
you can do generics but you'd have a concrete type for each SO
are you sure you just don't need inheritance?
Battle Manager - https://gdl.space/qusufiqula.cs
Spell Button - https://gdl.space/bogevowexo.cpp
Hey guys, I'm having an issue with these spell buttons i am instantiating, For some reason the on click event is not executing, I do have an event system in the scene. It looks like all the variables are populating correctly in the inspector but for some reason nothing happens when i try and click it. Not sure if it is somethhing wrong with the code or not. I copied the code for creating the buttons from another section of code when creating the enemy buttons and those work fine.
no, i want different items to store different scripts,
for example a consumable item to hold a script called consume and a sword item to hold a script called attack
some ideas:
BaseStorableClass implements: Name, Icon, SlotType
BaseStorableClass -> ItemClass
BaseStorableDataSO -> ItemDataSO
ItemClass implements Consume();
BaseStorableClass -> WeaponClass
BaseStorableDataSO -> WeaponDataSO
WeaponClass implements Attack();
thanks, i'll give this a try
How do I set my text to the following?
if (placeholderWords.Count == 0)
{
Debug.LogWarning("No more words in the list.");
inputField.placeholder.GetComponent<Text>().text = "No more words in the list!";
return null;
}
Set the value of the input field rather than the placeholders text
sorry wdym by set value of input field
I thought this is how you would set the placeholder text value, it works for my other methods
i.e.
public void SwapPlaceholderText(string newPlaceholderText)
{
inputField.placeholder.GetComponent<Text>().text = newPlaceholderText;
}
what would be the best way to get my jumping and falling animation to play i tried with velocity but given my platform isnt flat it keeps triggering at the wrong time
check if velocity.y is bigger than a certain threshold for jumping and do the opposite for falling
i tried that but the issue im having is since the platform is hill shaped
it keeps triggering
should i just raise the threshold?
you can try to add an overlap circle beneath the player and if it's colliding don't play the animation
if you raised it, it might look off
how would i do that?
As Moe said, you definitely want a grounding check
Raycast() or OverlapCircle()
Use a layermask to only check if it's on the ground layer
If they return values showing it hits the ground, then you are on the ground, and you should not use the jump OR fall animations
bump
Did you log the events and see if they are being called
create an empty, put it at player's feet
adjust the variables to suit your script
var hitCollider = Physics2D.OverlapCircleAll(empty.transform.position, Radius, 1 << LayerMask.NameToLayer("Ground"));
if (hitCollider.Length == 0 && velocity.y > jumpingThreshold) // Play jumping animation
else if (hitCollider.Length == 0 && velocity.y < fallingThreshold) // Play falling animation
I did, the event method is not being called
the CastSpell() method
it is like the buttons are not even interactable, almost like an eventSystem isn't present, but it is. Does it matter that the buttons are instantiated after the event system already exists?
so wait where does the empty game object come in
empty.transform.position
visualize it as if you're drawing a circle around it with a "Radius"
Could be UI specific like the raycast isnt being detected. Button has interact unclicked so try that first.
try checking if there's no other ui elements above it blocking the raycast
ah so this is creating a circle of radius 1 use a layer mask to check if it is grounded
then it checks if the hitcollider is equal to 0 and the velocity is above the threshold then the other does the same for falling, do i understanbd correctly
also, is the empty game object a child of the player?
not a radius of 1, you edit the radius
var Radius = 0.2f; (adjust it to suit your game)
1 << LayerMask.NameToLayer("Ground") --> is for checking if you're colliding with an object with "Ground" layer
yes, so the circle always follow the player's feet
right let me try that
do i use a serialize field to get the game object in?
doesn't matter, you can make it public or serialize it
How do i set an object's rotation to 0?
Thx
my VS Code editor keeps giving me almost 30 errors saying that (This project is not supported in C# Dev Kit.) how do i fix this?
here is the output
from the console
!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.
And !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
• Other/None
i've done everything listed on the !ide and it didnt work
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
specifically the one in VS Code
Show the extensions you have and the packages in unity
If you wanna show the log, use the instructions above
I have an enemy that is able follow the Player. It does this when it is in the distance of the Player, but when it isn't it stops. However, I don't want a full stop when the player exceeds the Distance from the Enemy. I want the Enemy to keep following for a few moments just in case he can catch up in time, and if it does then it keeps moving. ```cs void DetectPlayer() {
distanceFromTarget = Vector2.Distance(transform.position, target.position);
if (distanceFromTarget <= distance) {
FollowPlayer();
}
else {
StopFollowingPlayer();
}
} ```
Oh sorry, the image expanded when I clicked on it. You do have the right extensions
yeah
Ok, and packages?
i think from the sheer amount of em i think would be flagged as spam
let me see if i can find a way to show them to you
JUST show the Visual Studio Editor one
ok
Ok, good. Right version.
But you should remove the Visual Studio Code Editor package
Now show the External Tools window
i cant because it is installed as a dependency so the remove button is greyed out
also sorry for ping
Ah. Remove the Engineering feature to remove it. But it shouldn't be too big of a deal.
Close VS Code, click regenerate project files, and reopen it.
Also, you only really need the top two check boxes selected
how do i remove engineering feature?
ah i figured it out myself
ive done what you said and i get the same exact thing
28 errors and broken syntax highlighting
!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
• Other/None
hello, I was wondering, what exactly is the difference between installing VS community edition manually and then using it with Unity versus just installing Unity Hub, and adding VS community edtiion as a module?
Are there any pros and cons in or the other?
They were already linked to that
Edit: oh, did you do that for yourself? Sorry
Do you have any sdk error?
what do you mean by sdk error?
A popup on the bottom right od vs code saying you are missing an SDK
Restart your computer
If it is still there when you reopen, you need to manually get the sdk and restart again
(A restart is required to automatically set the PATH. You can do it manually, but you need to know what you're doing to get it right)
It SHOULD have been installed with the c# dev kit extension though (but sometimes fails to)
Hello friends, I have a little problem and it is that when I shoot upwards and I am crouched the bullets go in the opposite direction from where they are pointing as if they were going towards the direction inside the player and I think that the code has something to do with it ``` private void Shoot()
{
audi.Play();
Ray ray = fpsCam.ViewportPointToRay(new Vector3(0.5F, 0.5F, 0));
RaycastHit hit;
Vector3 targetPoint;
if (Physics.Raycast(ray, out hit))
targetPoint = hit.point;
else
targetPoint = ray.GetPoint(1000);
var bullet1 = Instantiate(bullet, muzzle.transform.position, transform.rotation);
bullet1.GetComponent<Rigidbody>().velocity = (targetPoint - muzzle.transform.position).normalized * shootForce;
}```
For anyone who uses visual studio. When using find and replace, is there some way to allow any character when filling in find? Kinda hard to explain, so I'll just show what I want:
Original find/replace
Find: dog1 is silly
Replace: dog1 is goofy
What I want
Find: dog[any character] is silly
Replace: dog[same character] is goofy
https://gdl.space/qumeponapu.cpp anyone know how I could put .normalize into this so I dont go faster diagonal?
it has fixed. thank you
movement.normalized
but wherr
Wherever you want. At the end of update or start of FixedUpdate (using Normalize()) or in the MovePosition on line 26 using the property
How is rigidbody accepting a float here for rotation
It really doesn't matter much where as long as it's after the getaxis and before the move call
Oh hey, look at that (what Mao said) haha. Missed that.
Is that not giving you an error?
Is there a way to have a float be tracked in another script? I have a float called timeElapsed but i would like to track it in a seperate coroutine via a parameter or track this value.
Wrap it with a class.
Or just use the reference to the instance that contains the float.
would the latter require a local variable outside of the coroutine?
A variable outside the coroutine wouldn't be local anymore - it would be a class member/field, but yes it would require that.
thanks
I just realized i was editing the weapon 😭😭😭
I'm having trouble finding any help on what to do if I want to read files from a folder in the game once built
does anyone know how to do that or anything I could reffer to for help?
Alright so I know I can't reference scene objects in the inspector for a prefab but how am I supposed to drag "Player Goal" and assign it to player goal in my script without getting this mismatch error?
And yes I configured my IDE as I was told to do earlier, and there aren't any errors popping up in my script
Does anyone know how to save my game's details for the next time it's played?
I can't use player prefs for everything.
Is it possible to save things like transforms, positions of all enemies and things in Unity?
Does it require an asset?
What are some good assets for this task?
Need to serialize your data usually by json then when you relaunch the game you deserialize it all
Have you made the mistake of setting your Player Goal type to prefab?
Instead of GameObject?
Such as public GameObject goal?
Instead of public Prefab goal?
How do I save it though?
JsonUtility or https://www.newtonsoft.com/json
Json.NET is a popular high-performance JSON framework for .NET
Thank you!
Basically, everything you want to save should have its own data container class
then you write all that data as json
So it wouldn't derive from monobehaviour?
The class?
It's just data that you'd repopulate the next time you start the game. You'll have to have a custom load manager as well to know what type you're populating this data into.
Ah I'll have a look, thanks
Appreciate it
Ideally you'd want to ID your SOs too so you can populate your save-specific data objects with those IDs. This also helps by identifying types upon deserializing your data, otherwise you can split types by directory or just type check.
Having a dictionary of your SOs to compare IDs will just allow quick lookup to reinstantiate and populate your objects
Ohhhhh
Yeah thank you
What do you mean then? What's the point of making playerGoal = GameObject.Find("Player Goal"); if you want to set it in the editor?
If you want to set it in the editor by dragging, first step is to delete that line.
Find is VERY error prone
They have no reason to use it either.
At the LEAST use the type version. But if you can, never use Find
first !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
• Other/None
Ok...I deleted the code but it is still giving me that mismatch error, do I need to create a prefab of the Player goal?
Your ide isnt configured as the person above pointed out, you really should get that sorted first. Type mismatch usually means you had it serialized as a different type before so you need to update the reference
If I wanted to create a script that is assigned to each individual object in a seed based generation map, which has its own type, hit points, drops, etc, should I use enums or class?
I don't completely understand how unity works, but I want to create an instance of the class for each object
does this mean adding the script component to each object?
does that accomplish what I'm trying to do?
In what way would you use an enum? To know what values to add to the new class?
That could be fine if you have distinct types you'll use
like rocks, trees, bush, etc?
I'd need to see what you're trying, but yeah, do the IDE first
Ok sure. Use enums for that if you want.
In the end you'll be using classes though
The enum would only be for knowing the type of class to add
I want to make the code as efficient as possible
The choice you're presenting wouldn't really affect performance one way or the other
But also, I wouldn't worry about performance at this point so much
I'm trying to get the enemy balls to go toward the player goal if that makes sense
like just targeting it and going in that direction
Ok, so drag in the player goal.
Did you fix the ide?
should I create the enum in a seperate class from the one I will add to each gameobject?
well it's saying I need to install the unity extension, but when I go to click install nothing happens so I'm kinda stuck right now
An enum doesn't have to be in a class.
I mean script
Sure if you want. Really doesn't change anything. It's personal preference.
I do when it makes sense, and don't when it doesn't
Are you using vs code then?
alright thanks I think I'm starting to understand it better
Hello, I'm trying to make a movement system in the style of the collide and slide algorithm but the walls kill all velocity and the ramps make you much faster
This is the script:
https://hastebin.com/share/agoqurucad.csharp
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
one sec
meant that to be mp4
bruhh does unity srsly have accessibility incompatibility
I can't make variable unaccessable except through method
public ObjectType getObjectType()
{
return objectType;
}```
I don't want the variable itself to be accessable directly, I only want it to be accessed through the get method
because I don't want the objectType to be changed
Sounds like a perfect place for a property then
okay then, what is that?
public ObjectType objectType { get; private set; }
[SerializeField] private static ObjectType objectType { get; private set; } = new ObjectType();
Is ObjectType a class?
Ok then, sure
Oh, it has to be public
alright
So then you don't do new on it
That is irrelevant. Get the idea of scripts mattering out of your head for now
ok
Classes, Structs, Enums, Types in general are what matter
No. Not at all
At the top where you write public class ObjectData
public class ObjectData : MonoBehaviour this is a class
public ObjectType getObjectType() this is a method
I'm still getting inconsistent accessibility
could you explain further?
public ObjectType objectType { get; private set; }
data.objectType
You can just get it directly
and I can't edit it?
It is publicly accessible