#๐ปโcode-beginner
1 messages ยท Page 838 of 1
i have many potential flood points
depends on what you are doing
i want to create my own gen ai and agents
what's needed for that
Maths, advanced maths
actually would i even add 7 in this example or would i only add neighbours i've "passed"?
for gen AI you need to be very good at maths
please go somewhere else
Again, some basic reading would be a good idea.
This is a server for Unity development. None of this is Unity.
physics too? and chem?
Pretty sure that when you add an unvisited neighbor to the stack (or queue), you can mark it as visited/explored right away
i was thinking before the foreach. you'll get duplicates either way, but the order of duplicates would be different
i think it's better in one iteration and worse in another? i haven't thought about this kind of thing in a long time and tbh i need to stop procrastinating ๐
im kind doubtful so uk
Dude unless you are gonna take this seriously please go find someone else to harrass with this. And again wrong server
uhm sry i didn't meant to harrass u , but im rly new to these things
Please stop flooding this channel with this unrelated convo. There are people being actively helped here. Go somewhere else (other server)
@sour fulcrum it seems like you had a question but it kinda got lost
what was your question, also are you going for breadth-first or depth-first
We've said a different server or at least a different channel. And someone is trying to get help with something
that question is new to me so i'm not sure, give me a sec ill give a bit more context
uhm i will be getting on street in next 4 months if i dont pay my debt so it would be very kind of you if u let me clear my doubts
It would be very kind of you if you did that elsewhere
im trying to get help too but this is the only server i found
Agreed
Dude go find a different server, I can DM you some I know.
alright i will go , thanks
assuming for each tile you go NESW, starting from 3, assuming 11 is blocked(?), would you expect it to go
3 4 8 12 7 6 10 9 5 0 1
or
3 4 7 1 8 6 0 12 10 5 9
You won't get duplicates on the stack if the explored cells are marked as such right after adding them to the stack. It is just matter of whether to add cells to the stack that might be duplicates or just ignore them immediately if they are.
ok so i have these tiles, and i have them like voxelised into a little grid right.
the voxels that aren't being drawn in are "uninitalized" right now (just an enum). I need to flood this space in a way where the green floods into the uninitialized voxels (apologies if i'm misusing a term or something)
I guess the problem im running into based on how yall are responding is that my flood points are pretty varied and inconsistent in placement
don't you usually mark cells as explored when you, yknow, explore them? you didn't include that in the pseudocode
DO YOU NEED A LAPTOP TO GET STARTED WITH CODING AND UNITY PROJECT
can you just fuck off
<@&502884371011731486>
They are guaranteed to be explored in the future, so might as well mark them explored when queuing them
be courteous. don't spam all caps and bold.
but no, you don't need specifically a laptop.
So you can avoid doing the extra check after dequeuing/popping from the stack
thnx i will get everything started pretty soon enough
Is there an actual question here?
Obviously you need a computer of some sort to get started with Unity.
that's a good point, i don't think i've gone through that process
ohk thanks for your help
Is there a way to speed up Vector3.MoveTowards?
transform.localPosition = Vector3.MoveTowards(this.gameObject.transform.localPosition, Vector3.zero, Time.deltaTime);
``` hers the code I'm using(it is in fixedUpdate)
increase the max delta
multiply Time.deltaTime by the desired speed
Should have added that true. Thought there are many ways to do it so chose to leave it out of the pseudocode. I can edit it there
The third parameter is the max amount you want to move in one step
Increase that
right now you have a hardcoded speed of 1
Okay thanks a lot!
damn, i refunded my tech skill tree and took everything out of competitive programming...
Please do not use that abbreviation LMAOO
oh, yeah
xDDD
What's the oppisite of hardcoded? Softcoded? Idk softcoded sounds weird
variable (adjective)
Ahhhh thought so
So what is the point of the flooding? Find every cell (directly or indirectly) connected to the green cells and change their enum state?
yes
maybe my brain was using the term too literally vs programmically
imagine like literal flooding
And the yellow ones presumably work as boundaries for the flooding? You don't want any liquid sim (or flooding animation) happening there though do you?
correct, but the work is already done there so-to-speak in the sense that this flooding would just be checking if current voxel is green then "somehow" making any white/empty tiles green (via the solutions we've been talking about)
yeah nothing fancy nor realtime, this isn't for actual flooding ๐
I multiplied it by 0.5f it is somehow slower
you made it slower and it's.. slower now?
what did you expect
I realised that now lol
MoveTowards takes a max delta
if you have a deltaTime of 0.1 and a speed of 2, if you multiply those together, you get 0.2, the amount to move in 1 frame
deltaTime = 0.1 --> 10fps, so with 10 frames (1 second), you move by 2 (matching that initial speed)
Also @sour fulcrum this might be a good usecase for a Job, but make it work first, jobify it later
I might just make into a spring joint, i think that would be better for a REPO-like grab system
Ok. So what you could do is start by finding all the green cells, marking them as explored and adding all of them to the stack/queue. Then you can start running this #๐ปโcode-beginner message algorithm by going through every element in the stack and adding all the neighbours which are not yet explored to the stack/queue (you would also not want to add yellow cells there).
Assuming that you have easy access to the state of each cell, you don't need to keep track of the explored cells separately, instead you can turn each cell to green immediately in the foreach loop if it is unexplored (not green or yellow) and you can then treat cell explored if it is green by color (or whatever state the green color indicates in your case). The whatever structure you have for the cells (3d array?) would serve the purpose of the bitset Chris mentioned here #๐ปโcode-beginner message
thank you very much, i appreciate the time and advice a lot ๐
ill let you know how it goes
No problem. Feel free to ask if anything is unclear. Note that I wrote the pseudocodes from memory, they are not tested to work. You can google iterative BFS/DFS implementations to find a lot of similar solutions (filling and searching is very similar in nature). Once you get it implemented, you can try changing the stack to a queue or other way around and see if it affects the performance. Using stack makes it depth-first and queue makes it breath-first
One important considerations is also how many ways you want to search from a given voxel. The less is more efficient but you need to do more if you need the fill to snug through corners or edges. The flood fill wikipedia page has a nice visualization of the effect in 2D with 4-way and 8-way fills. In 3D, you can do 6-way, 18-way or 26-way fills. Looking at the image you send of your level, 6-way fill is probably what you want
Just for extra demonstration, I can go through this example assuming a 8-way (diagal neighbours also checked) breath-first implementation (queue) of the algorithm explained. So the algorithm would start by collecting all green cells and adding them to the queue which would then only be [ 3 ]. Then we would start the while loop which takes the 3 out of the queue and adds all the neighbours (which are white) of 3 to the queue and colors them green. The queue would now look like this [ 4, 8, 7, 6, 1 ]. Now 4 would be removed and nothing added since 4 does not have white neighbours anymore. The next iteration would remove 8 and add 12 and color it since that's the only white neighbour. Now the queue would look like this [ 7, 6, 1, 12 ]. At this point everything except 11, 10, 9, 5 and 0 are colored green.
7 has an unexplored neighbour 10 so that is added and colored. 6 has unexplored neighbours 9, 5 and 0 so those are added to the queue and colored green. Now the queue is as follows [ 1, 12, 9, 5, 0 ] and the whole room except 11 is colored green. The algorithm doesn't know that yet and goes through each of the cells in the queue removing them one by one, since it doesn't find any new unexplored (white) neighbours for any of them, the queue will become empty and the algorithm will terminate right there.
How performance heavy is adding and removing a component during runtime?
Impossible to say. Doing so is normal workflow though.
Ahh okay thanks
Though, if you're needing to do that, you might consider just using prefabs or prefabs variants. But it depends on what you're doing.
yeah, give us some more details and we might be able to give more specific advice
Hii, is it possible to have time scale affect particles?
oh, interesting, i always figured that particle systems would respect your timescale
my first thought would be to write a script to handle that
just call it ParticleTimescaleHandler or something and have it set the simulation speed of the system
By default it uses the regular delta time, but there's a check box to tell it to use unscaled delta time somewhere in its settings, if I remember correctly
oh, yeah, then that should work fine
I looked at the settings, saw that property, and decided "oh, but that's not the timescale, that's delta time!"

My outputted reticle position does not at all match the position on canvas, but i have no idea why, can anyone please help me?
isn't the position there the anchoredPosition of the recttransform like i mentioned before
I dont think so, cause then theres anchors, yk, but im not a remotely smart lad, so could be wrong
those are anchor positions, not the anchored position
The min/max anchors tell you how much you stretch based on the size of the parent RectTransform
it's the fraction that you, with a width/height of zero, try to occupy
(so, anchors of 0.5 mean you don't stretch at all!)
https://docs.unity3d.com/Packages/com.unity.ugui@2.6/manual/class-RectTransform.html
Pos (X, Y, Z): Position of the rectangle's pivot point relative to the anchors. The pivot point is the location around which the rectangle rotates.
the anchors being together is what makes it not stretch
So, would anchored position save me then here maybe?
Well, yeah, but it just all kinda broke every time, so i keep trying to modify it enough for it to work
use anchoredPosition and make sure your anchors are set properly and make sure you're using anchoredPosition consistently.
Nah yyea nah,it doesnt work, unity sucks sometimes
or ig i sucks at unity sometimes
What do you mean it doesn't work? Is there an error?
Are the values not what you'd expect? Anchored position.
Yeah, the y pos is like 2-300 too high
compared to the value in the inspector, or compared to screenspace?
Inspector
It's on scaled, but its still not reacting at all, strange
I'm following a tutorial and I'm really confused why the scoreboard is being referenced like this instead of with a [SerializeField] and then dragging it into the inspector? The reason the guy gave was
"There are a lot of different ways to get references inside Unity. Weโre most familiar with using SerializeField and dragging objects into the Inspector, but in this case thatโs probably not the best practice. A Scoreboard is currently a MonoBehaviour attached to a GameObject in the scene, while your enemies are prefabs โ and from scene to scene those prefabs might not persist. You might even want to instantiate enemies at runtime, and they wonโt be able to spawn with a SerializeField reference to a scene object. In that situation, it can be a good idea to obtain that reference in another way."
I don't really understand this explanation. Why wouldn't enemy be able to spawn with a SeralizeField reference to a scene object all of a sudden? I just don't see how scanning the entire project with FindFirstObjectByType<Scoreboard>() is better?
"You might even want to instantiate enemies at runtime, and they wonโt be able to spawn with a SerializeField reference to a scene object."
this is the exact reason why
idk why I find this so confusing
So prefabs can reference other prefabs in [SerializeField] when instantiated but not objects in the scene?
The person is basically demonstrating their lack of skill because this is a shit take
Finding objects by name/type should be done sparingly as its slow
they did say that tbf
think of it this way, how would you get a reference for that scene object in the prefab?
The good way to overcome the issue is that the spawned objects get initialised and given the references needed
but thats not easy for beginners
dragging it from hiearachry into the [SerializeField]?
Most beginners of unity have no prior programming knowledge ๐คทโโ๏ธ
have you tried it? you will be surprised
a prefab referencing something in the scene is like a boxed blender at walmart having a reference to the wall socket in your kitchen
what are you smokin
I haven't tried it because I was told it doesn't work, it just made logical sense to me but no point if it doesn't work I guess
a scene object CAN reference a prefab and thus can give shit to instantiated stuff
what if I just made the Scoreboard a prefab then referenced it that way in [SerializeField]
then they're both prefabs
fuck it just read this https://unity.huh.how/references/prefabs-referencing-components
Assets can't directly refer to Objects in Scenes, but their instances can be configured with those references.
So could I just make the Scoreboard a prefab and reference it through [SerializeField] that way to dodge the issue?
The way to really solve the issue is to just setup what you spawn after is created
[SerializeField]
Enemy enemyPrefab;
//...
Enemy newEnemy = Instantiate(enemyPrefab);
newEnemy.Init(scoreboard, coolShit);
^imagine this is in a component already in your scene so it can serialize a ref to scoreboard
perhaps it could be named EnemySpawner ?
Both Base Enemy and Scoreboard is in the Hiearachy but I wouldn't be able to drag Scoreboard into a [SerializField] on the Base Enemy because it's a prefab?
oh wait it's an instance of a prefab
yes thats correct
so it's also an object
so these can just have a serialized ref
But an instantiated prefab would not and requires manual initalisation
prefabs are also objects (specifically gameobjects), just not scene objects
everything is an System.Object
but I have a [SerializeField] GameObject destroyed VFX but it's a prefab that I drag into the field so that's why that works?
cus its a prefab ASSET
But I wouldn't be able to do the same thing is Scoreboard because it's a game object in the scene?
YES
think logically, how can a prefab asset possibly reference something in a scene when it may not even be loaded??
what happens if you tried to use that prefab in another scene?
(also just as a vibe check, this is a very big thing beginners "struggle" to learn so don't stress if it feels weird)
Yea that is true. The important thing to understand is that when we "load" a scene unity just makes everything that was in the scene fresh
Yea this is the first thing I've come across so far that I'm really struggling to understand, referencing things in different ways. So far it's just been a memory game apart from this
An asset is different because its constant and the same and wont go anywhere
so the reason we can't do it isn't "You might even want to instantiate enemies at runtime, and they wonโt be able to spawn with a SerializeField reference to a scene object" But it's that we literally can't because unity doesn't let us even if we tried, and not because of something I 'might' want to do later on?
As in, it's not something I 'could' do now but 'shouldn't', it's that I literally can't because unity doesn't allow it?
Its just not logically possible with unitys design
and thats fine and normal and expected
its a bit of a catch 22
It could be overcome but would be dumb and unreliable
yeah even if possible, it wouldnt be advisable
so scoreboard = FindFirstObjectByType<Scoreboard>(); is the best way to do it?
It's really confusing trying to keep in mind how everything links together in scripts - inspector - prefabs - hierarchy
Ok I'll trust the process ๐
Thanks for the help everyone ๐
hello, im trying do a movement system for the camera, this error appears:
Movement.Update () (at Assets/Movement.cs:24)```
the line was is wrong is
```cs
GetTransform.Translate(new Vector3(horizontal, vertical, 0f) * Time.deltaTime * velocidade);
im sorry for dont have some description about the error
but, basically, the script what contains this line was used in a "Main Camera"
idk if have a problem about this
i can show the code if was necessary
!code
๐ Large Code Blocks
Use links to services like:
https://pastes.dev/
https://paste.yunohost.org/
https://share.sidia.net/
https://paste.ofcode.org/
https://paste.myst.rs/
๐ Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
show Movement.cs
okay
using UnityEngine;
public class Movement : MonoBehaviour
{
private Transform GetTransform;
private float horizontal;
private float vertical;
[SerializeField] private int velocidade;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
horizontal=Input.GetAxis("Horizontal");
vertical=Input.GetAxis("Vertical");
GetTransform.Translate(new Vector3(horizontal, vertical, 0f) * Time.deltaTime * velocidade);
}
}
use the links instead doesn't work well on mobile especially missing lines
GetTransform is null as the message pointed out, so you did not assign it
sorry, i didnt understand
Where did you get the idea to do this "GetTransform" variable?
GetTransform needs to be assigned a value cause its null
also weird ass name lol
because i remember in tutorials we create a variable with the component name backward
GetTransform implies a method, also what ๐ค ?
Imagine a programming language where you need to spell variable names in a specific weird way for a hidden behavior to be applied to them. ๐
the type of variables yeah?
No. There aren't many languages that limit you in terms of naming your api.
sorry, but i dont understand this
ill read again
wait a sec
Does anyone feel like helping me with understanding how to make a camera reset feature in a gyro experiment I'm working on? I have been at it for like a week and can't get it right. ๐
what does that entail?
Talking to me?
yes; what would a "camera reset feature" be?
No...
thanks! ๐
I really recommend you learn and fully understand this but here is what you probably ment to do:
https://pastes.dev/V9y2FPEXjW
"transform" is a built in variable inside all MonoBehaviours
Once I have a usable build whatโs the normal pathway to trying it out and maybe publishing it privately so someone else can try it as well
For trying it out, just launch the exe. Or "build and run". To share, just share the files of the build(might want to consider archiving the folder) in any way you desire.
There are some platforms that allow free publishing, like itch io, but I'm not sure if you can do it privately.
Also, this is not a coding question...
hey, is there a way to make this health bar centered? the only way I know how is to manually adjust it until it "looks right". Is there a button to do this automatically?
yes that is correct
Should just be able to center the pivot as you have it and zero out the coordinate space assuming the canvas is child to your character
and modify the y a bit manually
ahh ๐ thank you, i got it ๐
Hello,
I am watching a youtube video for attacking other troops, the person has setup a trigger sphere so when a troop enters the collider it will set them as their target. He recently added the "OnTriggerStay" function, but kept the "OnTriggerEnter", but I'm not sure why. If the code in both stays the same, whats the point in keeping "OnTriggerEnter"? Unless im missing something it would be best to remove the OnTriggerEnter event?
private void OnTriggerEnter(Collider other)
{
if(isPlayer && other.CompareTag("Enemy") && target == null)
{
target = other.transform;
}
}
private void OnTriggerStay(Collider other)
{
if(isPlayer && other.CompareTag("Enemy") && target == null)
{
target = other.transform;
}
}
My first thought is that OnTriggerEnter is set the first location of the enemy
And the OnTriggerStay is updating of the enemy location if he still inside the trigger area
from my point of view OnTriggerEnter is not useful, as if it was removed then OnTriggerStay would set the target value anyway? Not sure if im missing something
it really depends on how you want to check for and assign the target. OnTriggerEnter will only run the check once when the object enters. OnTriggerStay will run the check every FixedUpdate . . .
Actually you are right, is not helpful you can remove OnTriggerEnter
he said he opted to use the stay event because if an enemy was killed whilst another enemy is in radius then the a new target would not be used, which i think makes sense
thank you for the clarification guys ๐
if you only need to check once, then OnTriggerEnter is the better, more performant option. you can use OnTriggerExit to check if that enemy left the trigger, then set the target to null . . .
Better way to implement ๐๐ป
- Enter = pick target quickly
- Stay = pick a new target already inside
- Exit = clear target when it leaves range
Do not take it as ultimate solution but to understand how it works
a better method is when an enemy enters the trigger, add them to a list. then choose a target by iterating the list and selecting the first one, or by distance. when an enemy leaves the trigger or dies, you simply remove them from the list. this avoids calling OnTriggerStay every FixedUpdate . . .
@stoic mural Don't post slop code here. If you don't have the answer don't delegate it to LLMs.
good idea! thank you.
is it possible to add descriptions to components?
Its not immediately clear that this is for "is troop in range", I imagine a troop could have many colliders, which could make it hard to know which one is for what.
You can put them on named game objects, or assign named unique physics materials with default values to differentiate.
so for the first option, id have
troop
- object named "in range collider" as a child of troop, with "sphere collider" attached to that, instead of the troop
events from children colliders should propagate to parents
Only 2d I think has weird behavior where collider placement matters for sorting layer when it's not on the object with renderer. 3d should be fine.
thank you ๐
I'm very confused by the velocity change function force mode. I have a simple movement script here and the speed keeps going up if I keep pressing the move buttons.
` private void Update()
{
moveDirection = orientation.forward * inputManager.verticalMove + orientation.right * inputManager.horizontalMove;
}
private void FixedUpdate()
{
MovePlayer();
}
private void MovePlayer()
{
rb.AddForce(moveDirection.normalized, ForceMode.VelocityChange);
}`
Just for clarity, vertical/horizontalMove are the x and y axis of a joystick/WASD input and orientation is an empty object in the center of my player object to keep track of which way he is facing.
I thought velocity change forcemode instantly sets the movement speed to the first input vector, in this case moveDirection.normalized. If I'm using a normalized movement vector, shouldnt the velocity always be 1?
hmm documentation says "Add an instant velocity change to the rigidbody, ignoring its mass." so I guess it adds 1 unity of velocity to the rigidbody every frame?
In this mode it is pretty much the same thing as assigning velocity directly to the object, only through AddForce method. https://docs.unity3d.com/6000.0/Documentation/ScriptReference/ForceMode.VelocityChange.html
If you have anomalous behaviour you should check what else affects it.
hmmm should be nothing else affecting it unless I missed something, but I'll keep investigating.
So you're saying if I run "RigidBody.AddForce(10, ForceMode.VelocityChange)" should it consistently move at 10 velocity, or is it adding +10 to the velocity every time the function is called?
it just sets it to vector length
oh yeah u right 10 is not a vector3 XD. hm this is still weird unexpected behavior imma try it out in a scene by itself maybe something else in my scene is messing with the physics... or maybe the physics settings.
AddForce will always add more velocity to that direction regardless of mode. If you want a specific velocity just set it directly
ah ok. I followed a pretty long tutorial series that used direct velocity changes, but the code got quite bloated and the direct velocity changes led to some issues that the youtuber fixed off-screen... and then another youtube tutorial said changing force directly is actually BAD and using addforce is better...
it seems he misrepresented how addforce actually works
I'm gonna just try to rebuild what I had before using direct velocity changes and just pay more attention to what I'm doing so I don't lose track of how it all works ๐
Oh yea, that's correct, don't know why I decided it doesn't, maybe tested long time ago with default friction.
Neither of them is good or bad, they're just for different use cases. Setting velocity directly gives you snappy, instant movement but you have to manage it manually and adding more features like jumping and knockback is more difficult. AddForce gives you natural acceleration and deceleration and interaction with physics objects but you lose some control and you have to tweak it more to get it right
Yeah the tutorial series I was following got pretty bloated with features. Basic movement and jumping obviously, but wallrunning, wall climbing, dashing, sliding, ledge grabbing.
Some of them were direct velocity changes, but some stuff like the dash were impulse forces and sometimes the velocity would get set and override the added forces. Got really messy and hard to keep track of all the different conditions.
Sorry to ramble, but it's at least good to know that this is something that tends to cause issues when using rigidbody movement and it isn't just me being a complete noob.
I've only experimented briefly with physics based controller, but it absolutely possible to have a nice snappy physics based one. You usually want to increase gravity, and add linear damping and also control friction on surfaces depending on conditions. There's a lot of corner cases to handle but it's doable.
Yeah he makes a pretty sick rigid body parkour character controller by the end of the series ngl but again very bloated and confusing to navigate
my goal currently is to split it into different scripts and get a better grip on how and when it changes velocities so I can implement my own movement features without breaking everything
I just imported NGO and the unity multiplayer packages, but when i click start host i get this error and when I click start server i dont get any errors. Any idea what causes this? The error links to the default unity transport script. Not even sure where to go about debugging this
Can anyone help me understand this code I found from a tutorial?
enemy: (141.64, 99.92) reticle: (137.43, 94.11) Accuracy: 1462.082 I dont think that's right
float distance = Vector2.Distance(reticle.anchoredPosition, enemyLocalPos);```
This is the func
```c#
void ResolveShot(bool won)
{
Canvas canvas = reticle.GetComponentInParent<Canvas>();
RectTransform canvasRect = canvas.transform as RectTransform;
Vector2 enemyLocalPos;
RectTransformUtility.ScreenPointToLocalPointInRectangle(
canvasRect,
cam.WorldToScreenPoint(enemyTarget.position),
canvas.renderMode == RenderMode.ScreenSpaceOverlay ? null : cam,
out enemyLocalPos
);
float distance = Vector2.Distance(reticle.anchoredPosition, enemyLocalPos);
Debug.Log("Accuracy: " + distance);
Time.timeScale = 1f;
float hitThreshold = currentSize * 0.5f;
if (won && distance < hitThreshold)
{
Debug.Log("You won");
_enemy_anim.speed = 2f;
_enemy_anim.SetTrigger("Die");
}
else
{
Debug.Log("You lost");
}
}
Please help me figure this bit out cause I am using anchored pos but its still breaking
have you tried logging the 2 values you're actually feeding into Distance
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #๐โfind-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #๐ฑโstart-here
Im so dumb, the enemy localpos is wayy of somehow
tbh i was hoping to dm them, plus im hella anxious rn
we don't do dm's here, sorry
ok, do i just send it here?
!code
๐ Large Code Blocks
Use links to services like:
https://pastes.dev/
https://paste.yunohost.org/
https://share.sidia.net/
https://paste.ofcode.org/
https://paste.myst.rs/
๐ Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
DM's would negate the point of having a community server to begin with ๐
i could probably help, but i'm also fighting a deadline and can't guarantee availability. if you DM'd me you'd just end up wasting your own time lol
oki thx
thats the point of the channel
its like going to talk to your professor/teacher and then just sitting there silently waiting for them to guess what you need help with
Yes ๐๐ป send your questions as many as you want and wait to replay ( you will get one) and try again to solve it ( if it works then good) and if donโt then ask again and we will try to help you ( donโt forget to help another person here) and it okay if nobody catch it on first try just try to make your issue explaining clearer
Do you want local or world position? Local is the objects position relative to its parent
anyone here ever used the meta xr toolkit. i am using it to setup full body tracking, everything works except grabbing and picking up items. i used an older system from before i introduced the full body tracking feature and now the old system doesnt work anymore
This just makes no sense
//doesnt work
void HandleShootingInput()
{
if (_dead) return;
if (Input.GetMouseButtonDown(0))
{
_faster = true;
shootingPhase = false;
_player_anim.speed = 2f;
_gun.active = true;
Time.timeScale = 1f;
_player_anim.SetTrigger("Shoot");
StartCoroutine(Flash());
ResolveShot(true);
}
}
IEnumerator Flash()
{
_gun.active = true;
Debug.Log("FlashCoroutineCalled");
yield return new WaitForSecondsRealtime(1f);
_player_anim.speed = 2f;
flash.Play();
_shoot.Play();
_player_anim.speed = 0.5f;
_gun.active = false;
}```
```c#
//works
void HandleShootingInput()
{
if (_dead) return;
if (Input.GetMouseButtonDown(0))
{
_faster = true;
shootingPhase = false;
_player_anim.speed = 2f;
_gun.active = true;
Time.timeScale = 1f;
_player_anim.SetTrigger("Shoot");
_shoot.Play();
StartCoroutine(Flash());
ResolveShot(true);
}
}
IEnumerator Flash()
{
_gun.active = true;
Debug.Log("FlashCoroutineCalled");
yield return new WaitForSecondsRealtime(1f);
_player_anim.speed = 2f;
flash.Play();
_player_anim.speed = 0.5f;
_gun.active = false;
}```
I need a bit of a delay before the shot cause of the animation, but this is just broken
(full script) https://codeshare.io/5ZvkWN
why not just trigger the animation from the input and call the shooting logic from an animation event
is your code separated into difference files ? you can make the movement separate in file that call 'PlayerMovement.cs" to handle the player movement logic.
what type of game you making?
I was looking for hours to find the reason I couldn't jump after running into walls, turns out my sphere was too big...
Oh nah, there aint a movement file, this is a duel
Huh, that makes sense tbh
Mainly cause its a mixamo read only animation and i cant really add on
you can from the fbx file in the animation tab
or duplicate the animation file and it will create a writable copy
Where?
Ohh i see
there should be an events foldout there
Guys what is a logic script? And how to figure out if the script im writing is logic or not
Where did you hear about a "logic" script?
By definition, every script you make contains "logic".
I mean when the script is a manager
Same question, where did you hear about that? And by definition every script contains logic.
What are you actually trying to achieve?
Why is my physics.raycast detecting Collider_01 at some parts of the screen?
It doesnt really detect what it should
everything is Collider_01
Search for Collider_01 in your hierarchy and see what the object is?
Perhaps your raycast isn't starting or firing in the direction you think it is? Or it is, but it's being blocked by said collider?
This is the part of my movement script that is called in update
Vector3 moveDirection =
transform.right * CurrentMovementInput.x +
transform.forward * CurrentMovementInput.y;
if (moveDirection.magnitude > 1f)
moveDirection.Normalize();
transform.position += MoveSpeed * Time.deltaTime * moveDirection;
``` It clips into objects, how can I prevent this whitout adding any performance-heavy tasks?
You can't move objects with transform.position you're teleporting it. You need to use a rigidbody with actual physics.
Hi, y'all, can anyone help me with this
'PlayerRigged (2)' AnimationEvent 'Shoot()' on animation 'mixamo.com' has no receiver! Are you missing a component?
I looked it up and i added a script onto the game object that just does this
using UnityEngine;
public class AnimationReceiver : MonoBehaviour
{
public DuelSystem duel;
public void Shoot()
{
duel.Shoot();
}
public void SpawnGun()
{
duel.SpawnGun();
}
public void RemoveGun()
{
duel.RemoveGun();
}
}```
But still get the error, any ideas?
Bro thanks. This was so obvious lol but i didnt check. Thanks for help
some fucking colliders were on the way
invisible wodoo crap
This is on a rigidbody, with actual physics. But would I call rigidbody.Move()? Or would I call rigidbody.AddForce()? I'd assume .AddForce since move requires a positon to move to, but I could be wrong
Oh yes I know but I was just saying this is on a rigidbody with physics
Also thanks for the help!
which object has the Animator component
It's whatever you want it to be because that isn't an actual defined term
Is this script on the exact object that has the animator? Not a child or parent object but the exact object?
Still what type of game you try to build 
Should you separate your Player movement into another script? And make method to handle the player and then the DualSystem script manage the dual interactive between the player and the enemy?
how would i be able to have my tank move by itself as an enemy npc if anybody knows roughly, i also kind of need the turret to be able to shoot and etc by itself too seperately from the main body
i have the player version worked out
and ill add health damage after the movement parts
you write a script to control it
it's a pretty vague question
i see
start with basic AI pathfinding first
Almost certainly the stuff like health and damage etc should be common to both the player tank and the enemy tank. I would expect generally that the two tanks are almost identical except for a couple of components, e.g. "PlayerTankControl" vs "AITankControl" scripts
assuming they are meant to be the same physically other than who controls them
yes
Untiy have what called NavMesh but you need to write AI to the tank โTankMovement.csโ
And โTurretHandler.csโ
okay cool, ill try that out, i've kind of done some of the navmesh stuff trying to follow the free unity learn tutorial but that one is a bit too lenghty in the code
okay i see ty
Happy to help โค๏ธ
hello i need i build a mobile app game the problem is the apk is installed but i cant open it i verified it its installed in the phone itself i tried everything using different project file and
- Confirmed it is not a Work Profile install (personal profile only).
- Confirmed Unity Package Name was set (you showed com.it7.cogniville in Player Settings at one point).
- Confirmed the Firebase Unity popup indicates your Firebase config contains com.cogniville.appname (and was missing com.it7.cogniville ), so you decided to use com.cogniville.appname .
- Confirmed your custom manifest includes the correct launcher intent on UnityPlayerActivity :
- android.intent.action.MAIN
- android.intent.category.LAUNCHER
- android:exported="true"
- File: AndroidManifest.xml
- Confirmed there is no Leanback/Android TV intent or feature declared in your Android plugin manifests (no LEANBACK_LAUNCHER etc.).
- Confirmed your UI reference resolution is already 1920x1080 (CanvasScaler)
The big question is what happens when you try to run it? Use LogCat to check the logs.
I canโt run it. It installs, but I canโt open it. The app doesnโt show up on my phone, and I can only see it as installed in Settings. Thereโs no Open button there either.
how did you create the app
by unity just clean build on android platform
and how did you install it?
by transfering the apk thru google drive to my phone and installing it in my file manager in the phone
And something like this should launch it: adb shell monkey -p your.package.name -c android.intent.category.LAUNCHER 1 if not you're missing an appropriately configured Activity in the android manifest
This is sideloading - you should use adb install or build and run through unity
Yessir
Yeah, its a western, I have 2 dif types, duels and town shootout but that one is nearly built already
Fixed it
Hi! I wanted to know how I could do something like the On Click() from the button component for my own scripts!
It is a UnityEvent
Okay thanks!
have a problem over here
my mesh moves when animation played
instead of an object
found the problem
its due to copy pasting having the same mesh
a bug of some sort
hello, in a Flappy Bird tutorial, i used a canvas from UI option when u right click in Hierarchy, but, the display now is soooooo big, is there a way to fix it?
the positions arrows are from a gameobject, in the normal size, if u see
the UI is so big
i am surprised cuz when u click in Game tab the game are normal
This isn't a coding question.
This is also how screen space UI works, it's not in the world. The white box you see in your first screenshot represents your screen, and those elements will be where on the screen they lie.
I am making a game and I used a tutorial and it is for vr and was using open XR but he has a box under android called oculus but when I looked for it was not there here is the video:https://youtu.be/nll9A1aHoM0?si=2kEH4ZeRtsW1rCRy the box is on timestamp 5:09
Hi guys! This is my updated tutorial for How To Make A Multiplayer Gorilla Tag VR Fan Game in 2025. This is an updated tutorial from my last tutorial that I made a few years ago. All the links that you need are down below (under the Discord links). Please comment down below what videos you want me to make. Thanks for watching!
**Set rendering mo...
i just started learning does anyone know any good courses or tutorials
!learn
:teacher: Unity Learn โ
Over 750 hours of free live and on-demand learning content for all levels of experience!
Hello! I'm very new, I am trying to make a simulator with generated planets with multiple environment, I've looked at a bunch of tutorials but all of them are only for one type of biome and based on how it works I can't seem to add more. I need around 5-8 separate biomes and I'm struggling to add even one.
scope too big for the skills you have right now
try participating in some gamejams (you can find many on itch.io) to practice implementing many different ways of creating biomes in short sprints, and then take what you learn from that to make a larger project.
Well. That is a tough thing. Lists are usefull for that kind of work but you need to know shit
Hello everyone.
I'm kinda new in programming. I want to understand how to build system of destructions for environment like in Battelfield.
For now i only now that you can manually shatter object in Blender and than working with pieces in Unity, but its looks like very complex and not optimized. I saw in Unity Store asset that can do it with any object.
Can you give some advices in which way should i looking?
Well you could use the asset you found.
It's a very advanced topic, so if you're new you might want to start with something simpler
Got it)) But if you find some materials about it, please share. I have searched through youtube but nothing so far. I mean nothing that i can understand.
I know its too early for me but I'm curious about it.
write in whatever you need
You were told to post to #๐ฑโmobile
Huh?
Did I send this here? I'm such an idiot
Hii, I am starting to write code I know what i need to do just have no idea how to write it, I kinda want a grappling hook like LittleBigPlanet,
I was thinking of using a LayerMask so i can choose what you can grapple to and a LineRenderer + DistanceJoint 2D to make it functional
About the layermask, what if you grapple something that can't be grappled? Should the grapple fail or should it go through that object?
it should just fail
Okay, then you can't use that layermask directly in the raycast (or whatever you use), otherwise it will just ignore things that can't be grappled
You can use it to check if the hit object was on the correct layer after you detect the hit, though
Imma be so fr i hadnt even thought of that
Other than that, linerenderer + joint would work yeah
Or manually adding forces/adjusting velocity of the rigidbody, instead of using a joint
the only thing i noticed is when i enable the joint and i start hanging the rigidbody loses momentum at the bottom
i think it has to do with how the movement i made works but i am not sure
Show your movement code
๐ Large Code Blocks
Use links to services like:
https://pastes.dev/
https://paste.yunohost.org/
https://share.sidia.net/
https://paste.ofcode.org/
https://paste.myst.rs/
๐ Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
The issue is that you are overriding the velocity by setting rb.linearVelocity = ...
So the joint doesn't get to affect the velocity
How I solved it is use AddForce when in the air/when grappling
okay i did see such an thing is it smart to transfer the code so it uses that just in general?
You can achieve the same things with AddForce and modifying velocity. All AddForce does after all is modify the velocity
i am assuming to do that i just change for example for moving rb.linearVelocity = new Vector2(moveInput * moveSpeed, rb.linearVelocity.y); to like rb.AddForce(moveInput * moveSpeed, 0, 0)
What I like to do is something like cs var targetVelocity = moveInput * moveSpeed; var velocityDifference = targetVelocity - rb.linearVelocity; rb.AddForce(velocityDifference * snappiness);
So basically add the "difference to desired velocity" as a force. This way you won't overshoot.
snappiness is just a float that controls the acceleration/deceleration speed (and you could have different values for this based on if you are on ground, in the air, grappling, etc).
But the common, simpler way is to just use AddForce like you just showed and have some drag (linearDamping) on the RB to limit its speed
Okay ill just try the simpler way for now and if i have time for the other way ill try and implement that
but real quick back on to the grapple basically what id want to do is:
OnMouseDown > Raycast > If collides with LayerMask > Enable Joint + Line with anchor on mouse position
That sounds reasonable, is there an issue?
no just a side question to it doesnt really matter if it does or not but does that mean that it will only connect to the sides of a sprite?
Not 100% sure I understand but the raycast doesn't care about sprites, it cares about collider components
so if it collides with a BoxCollider so to say it will put the Anchor on the sides of said BoxCollider instead of the centre so to say
Oh, you'd set the anchor to the exact hit point that you get from RaycastHit2D.point
RaycastHit2D is what the raycast returns to you
@opal plume Don't post off-topic here
If you'd rather be working on your game you could just actually work on it instead of trying to find the best hallucination engine to use
What would be the right channel then?
There's no off-topic on the server. Read #๐โcode-of-conduct
Where can one post about how to use Unity with local AI then? Seems like some here would be interested
I see some posts about AI over in Unity talk? is that the right place?
@opal plume If it's not related to Unity workflow, it's not related to Unity. Find relevant community interested in AI slop
Oh I see. You are and I guess via association, Unity, are anti AI. I will move one then. Thanks for revealing that.
Why am I getting this even though the class I'm instantiating is not a monoBehaviour
You are trying to create a MonoBehaviour using the 'new' keyword. This is not allowed. MonoBehaviours can only be added using AddComponent(). Alternatively, your script can inherit from ScriptableObject or no base class at all
UnityEngine.MonoBehaviour:.ctor ()
MyEvent:.ctor ()```
```C#
public class MyEvent
{
public event Action StartDialogue;
public event Action EndDialogue;
public void doStartDialogue()
{
StartDialogue?.Invoke();
}
public void doEndDialogue()
{
EndDialogue?.Invoke();
}
}```
```C#
public class DialogueEventHandler : MonoBehaviour
{
public MyEvent dialogueEvent;
public int test = 0;
void Start()
{
dialogueEvent = new MyEvent();
}
// Update is called once per frame
void Update()
{
if(test > 10)
{
dialogueEvent.doStartDialogue();
}
}
}```
have you saved all your scripts? otherwise you might have another script in the project with a MyEvent class that is inheriting from monobehaviour?
yeah I have saved and recompiled scripts multiple times
there's nothing really that has MyEvent the project is small and trackable
I'll try changing the class name to see what happens
Right click on the class name and go to definition
it goes to the class I sent, with no MonoBehaviour inheritance
changing the class name for some reason made it work
Make sure there are no other errors and build recompiled.
Also make sure you are not trying to use constructor in any MonoBehaviour object
I think i messed up with AddForce
Yes, probably. How about you look at the documentation for the function to see what parameters it takes and use the correct ones?
https://docs.unity3d.com/ScriptReference/Rigidbody2D.AddForce.html
So it needs to come from an Vector?
you cant just put a float or interger number
thats what i am understanding from that
that helped a lot already
The errors are gone at least the jumping tho isnt functioning but thats probably tweaking some numbers
Hey guys im wondering what might be a better way to code variable planets/levels.
I have randomized planet levels you can pick at will in a hubworld map.
They have different types such as farm planet or jungle planet, which changes alot per planet.
When selecting a planet would it make more sense to make every planet type its own scene or have a single "planet scene" that i can dynamically adjust to fit the planet type you selected
If they're randomized, you can't have one for every planet of course. So it seems like a single planet scene you generate the planet in, is the right way to go.
the blue tank ai enemy wont move towards the red idk if it's cause of the nav mesh?
i havent done this before so im not sure if it's that good that there's uneven risen parts lol
How can I prevent my player clipping in/out objects it walks into? Here's the code being called in update
Vector3 moveDirection =
transform.right * CurrentMovementInput.x +
transform.forward * CurrentMovementInput.y;
if (moveDirection.magnitude > 1f)
moveDirection.Normalize();
PlayerRB.AddForce(transform.position += MoveSpeed * Time.deltaTime * moveDirection);
don't modify the transform
how are we supposed to know anything if all we see is this image and none of the code or setup..
also did you check the console window for errors/warning
that's also not how addforce works
it doesnt have errors, all i have so far for the script is:
my one classmate did the same one and his works so idk what i did diff
put some logs and see what is running and wat isn't along with logging their values
also wth kinda theme is that for VS ๐ค
dark theme my beloved
that feels unconfigured rather than a theme thing
my eyes hurt otherwise
!ide
If your IDE is not autocompleting code or underlining errors, please configure it.
Select one:
โข
Visual Studio (Installed via Unity Hub)
โข
Visual Studio (Installed manually)
โข
VS Code
โข
JetBrains Rider
โข :question: Other/None
its weird cause it does say Assembly C# instead of misc.. so its weird
ill try out ty
yeah but normally the Monobehaviour should be Green and Distance method should be yellow etc.
oh i see not sure im ngl
shouldn't monobehaviour be white in vs?
wait what
Transform is also white and should be green
I remember though VS has a weird theme too that also did some weird shit like this while still being configured.
OP needs to confirm by seeing if intellisense / suggestions still appear
huh i remembered types being white in some contexts
couldve confused it with the namespaces there ig
I did not mean to add a += there lol
so what's the actual code?
After my fix it is PlayerRB.MovePosition(PlayerRB.position + MoveSpeed * Time.deltaTime * moveDirection);
(I realised that i did not mean PlayerRB.AddForce lol)
this will make rigidbody phase through objects, MovePosition is meant to be used with Kinematics
don't retype code man
if you don't want it to do that you'd have to manually check collisions and prevent movement in that dir, otherwise use Velocity / AddForce
(commenting on the original message, to be clear)
you essentially ask us to check for issues in new code that is loosely based on what you have, instead of what you actually are using
Okay, my bad
(same for errors, just fyi)
It's not phasing through objects just jittering, but how would I use AddForce in this way? Just add ForceMode.Acceleration?
Wait actually let me just test it real quick
jitter probably because you have a dynamic rb with Moveposition
im guessing at times it tries to compensate
Yep it works! still some jittering when trying to move into objects though( A LOT less tho). How can I fix this? Or is it one of those things where there isn't a straight forward fix?
Yeah sure! One sec!
I see. Also I'd try calling the movement in FixedUpdate. See if that helps a little
Dynamic based rigidbody character controllers are a pain in the ass to get correctly working tbh
could you show your current movement code? i got kinda lost and i feel like i don't have the full picture there
I put it in FixedUpdate I got launched off the map lol
I put it back in update and I still do
odd
with addforce you should not add onto your own position and fixed/delta time
Why? It was working fine a second ago.
PlayerRB.AddForce( MoveSpeed * moveDirection, ForceMode.Acceleration);
instead of
PlayerRB.AddForce(PlayerRB.position + MoveSpeed * Time.deltaTime * moveDirection, ForceMode.Acceleration);
Well now I don't get launched off the map
Doing it in update will make it depend on the frame rate. More frames = more addforce calls
But now I slide around everywhere, maybe ForceMode.Acceleration is not a good idea
FixedUpdate runs at a fixed rate, so that would remove that issue
(It's ok to do an impulse force like the jump in update, though)
So how can I stop myself from sliding around?
Easiest fix is linear damping on the rigidbody and/or friction on the physics materials
Okay thanks!
Hey there, I'm getting a MissingReferenceException the moment I start the game, but everything is working completely fine. I've got this Lighter script attached to a lighter gameobject which is currently a child of the player
Start by selecting that error and reading the full stack trace at the bottom of the console window
It will tell you which code is causing the error
Something is referring to a Lighter that has been destroyed
I have a question about the rotation, it behaves odd, i think. What do i need to do to rotate the child object, like the parent object - in the 2D space
Not a code question but it behaves like that because the parent object's scale is not uniform
Rotating a child object with a parent whose scale is not uniform isn't going to do what you expect it to do
Every object's transform is relative to its parent, since the parent is 6 times wider on one axis, so will its children
That scaling remains in the same place no matter what orientation the child object is
Where do i have to ask this typ of question next time?
What ya trying to achieve?
to rotate it around itself and then do the same thing for the childobject. A bit like a arm
to build something like this
void Update()
{
if (Input.GetKeyDown(KeyCode.DownArrow)) // forward
{
transform.Rotate(Vector3.forward * 45);
}
} Can someone explain to me why, this only works ones. i would like to stack it, like 45,90,135,180 and so on
Vector3.forward is global, kinda like how "North" points to the same place everywhere in the world
transform.forward is the specific to that object
Rotate works in local space by default so that should be ok here
Nothing wrong in this code snippet, something else is causing it to not work somehow
Are you clamping or otherwise modifying the rotation anywhere? Or does it have other scripts/components that could modify the transform?
I'd expect that code to rotate it along its own Z axis, 45 degrees per key press
Additively
Randomized between a set amount of planets i want to make
Farm planet, forest planet city planet.
I would be changing the model of the planet and a few other factor like what enemies i have spawning. its not procedural tho
Surely still having a scene for every planet would suck because how would they all sync with other changes prefabs seem unreliable
If each planet is hand crafted, I would create separate scenes. The syncing thing is a non-issue if you're using prefabs? Unless you can think of a specific situation?
Hi! New to using IEnumerator. I'm trying to make walls lower and raise:
private IEnumerator RaiseWalls()
{
var t = 0f;
t += Time.deltaTime;
float percentComplete = t / 1f;
arenaWalls.transform.position = Vector3.Lerp(wallEndPosition, wallEndPosition, percentComplete);
}
private IEnumerator LowerWalls()
{
var t = 0f;
t += Time.deltaTime;
float percentComplete = t / 1f;
arenaWalls.transform.position = Vector3.Lerp(wallEndPosition, wallStartPosition, percentComplete);
}
but I get this error:
Assets\Scripts\Enemy\SpawnTrigger.cs(60,25): error CS0161: 'SpawnTrigger.LowerWalls()': not all code paths return a value
I'm not really trying to return any value
i jusy mean if i add a new feature to a scene i would have to go and add it to every other scene?
That seems like alot
What would be an example of a feature?
The proper way to handle shared things is to have a root/side loaded scene that contains it, so it exists when you need it.
For example, in the game we're doing, we have a bunch of levels - each are their own scene. However, of course we need to have the same UI/pause menu/gameplay elements between them so we have a LevelElements scene that gets loaded alongside any level.
When you leave the level , say to go back to the main menu, both the level and this LevelElements scene is removed.
All coroutines need to have a yield, somewhere.
Even if it's just yield return null, though if that's the case, then you're not using a coroutine correctly.
Also just reading your code, you're not using it correctly ๐
well yeah no crap man I said I'm new to using it. I'm using it wrong, that's why I came here
Relax
such attitude some people may have
Oh okay, nevermind then.
I'll just do the short version of my answer: you need to loop inside your coroutine to do the progression.
Hi everyone i took a break saved and closed my unity normally i open it and come back to this
Do you want an answer or not
Because you got one and apparently decided it was a personal attack
If you can't be told that your code is incorrect, don't ask how to correct it
Check your package manager and see if TMPro is installed or if there's an update.
Actually, that's referring to the UnityEngine.UI ... it's missing ๐ค
Check if that is installed in your package manager?
should it be in between there?
The Unity Registry option on the left
Well, check the Unity UI one first, that's the one it's actually complaining about.
2D Sprites, sure, if you're intending to use them.
yea the thing is all of em arent installed not even unity physics and indeed uGUI
thank you ill figure out if ill just restart with a new project or figure out everything thats missing
i never wouldve thought of that, no i have everything in 1 scene.
if i changed something about my player hud for example id have to change it in every scene
Prefabs?
Currently, if you have it in every scene you would if they're weren't using the prefab.
But a prefab solves that issue. Modify the prefab and it applies to every instance of it.
why can't I see recommended commands when i type in tran.. for transform in VS. I have downloaded VS community and have a checkmark at the game development box. I have no idea what to do. Can someone help me please?
!ide
If your IDE is not autocompleting code or underlining errors, please configure it.
Select one:
โข
Visual Studio (Installed via Unity Hub)
โข
Visual Studio (Installed manually)
โข
VS Code
โข
JetBrains Rider
โข :question: Other/None
Thanks!
@night raptor works like a charm ๐
now i can dynamically get which part of my rooms are playable space or void space ๐
I'd say 6.3 LTS (skiing game or not)
6.4 breaks a bunch of previous things so wouldnt recommend for beginners right now
Long term support, basically the supported/recommended version
ok so it is recommended to use 6.3
This is my Collectible.cs
using UnityEngine;
public class Collectible : MonoBehaviour
{
public float rotationSpeed;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
transform.Rotate(0, rotationSpeed, 0);
}
private void OnTriggerEnter(Collider other)
{
// Destroy the collectible
Destroy(gameObject);
}
}
pls ping if anyone responds
What kind of response are you looking for?
I followed the instructions given by unity but im seeing that its not destroying the apple
It looks like you haven't added the script to the object
oh, i had added the script to "apple"
OK, but I'm guessing apple does not have a collider on it. "Collectible_apple" does
yea
i added the script to Collectible_Apple and removed from apple and that fixed it
I'm modding a game with some particle systems in it, and I'm trying to modify the velocity over lifetime and it's weirdly inconsistent
For one set of particles it only applies the velocity if I set it to a constant value, for another it only works if I set it to two constants (with the same lower and upper bound so it should function the same as a constant)
What could be different? I can't seem to find anything that explains why they'd act differently.
(By doesn't work I just mean it doesn't seem to apply any velocity)
we can't really help with modding here, sorry #๐โcode-of-conduct
both because of legal issues, and also because modding imposes certain arbitrary constraints that we wouldn't know about (and wouldn't know how to work around)
Hello everyone !
So i have an issue with my AI not rotating nor walking correctly.
I've freezed all X Y Z rotation in the rigidBody. I want to ai to spin 180 degrees when touching a wall.
- When i remove the freeze in Y, the AI stop walking / start shaking
- When i put a random
owner.transform.Rotate(0, -36, 0);in the code, even with Y freezed, it work - The rotate() function is called, but does not work...
if someone can check at my code and explain me why the rotation doesnt work, i would be extremly thankful !
https://pastebin.com/SE54fnKV
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.
Here's with Freeze rotation Y disabled
you wouldn't want to modify the transform if you have a rigidbody, rotate via the rigidbody (and unlock Y rotation)
//if (owner.transform.rotation.eulerAngles.y < -360) owner.transform.Rotate(0, 0, 0); //if (owner.transform.rotation.eulerAngles.y > 360) owner.transform.Rotate(0, 0, 0);
you don't need this part at all btw
you should not be reading eulerAngles to drive these decisions, they won't necessarily be consistent
eulerAngles should generally be write-only
Oh, that's why... Alright, now the biggest issue is that when the Y rotation is unfreezed, the AI just doesnt want to move ๐
But thanks for the explanations !
Is it possible to force classes to implement Unity event method such as Update() and OnDisable() using an interface?
Like if I just make a simple interface with public void OnDisable(), will that work?

unity messages aren't particularly special outside of unity knowing about them
I kind of thought that, but I was also prepared to hear something like "they're super magic special messages that dont work like this"
Is there a way to not use friction and/or linear damping? These aren't working for my use case.
Come to think of it, how does Unity know about the very existence of those methods at all? I mean the MonoBehavior class doesn't force a class derived from it to implement those.
Some kind of reflection magic?
it has "Update" hardcoded in the engine
messages are called via reflection, yes
you could make an opposing force that acts exactly like damping/friction, aka recreating those thigns
Ahh it is all magic to me
you have to use "opposing force to slow me down" in some capacity if you want it to slow down on its own. rather than recreate it, why not investigate why it isn't working for you?
for future reference, for stuff like "can i do X" within the language just try, tbh
The friction and linear damping are slowing my fall down, i mitigated this by checking when the object is in the air then making the dampening 0. But it still slides or feels floaty even when high
the damping and friction to be clear
linear damping would, friction would not unless you were also touching a wall (which you can configure to not give friction)
And how can I do that?
which part?
You can always just modify the velocity directly for maximum control.
Lots of people underestimate how tricky it is to make a movement controller that feels good though. Not beginner suff IMO
making the wall frictionless? that would be done with a physicsmaterial on the wall
friction would not unless you were also touching a wall (which you can configure to not give friction)
hmm okay
anyways if "friction" is making your character not handle well while you're in the air and not touching anything, it's not the friction.
wait true
this would be RigidBody.linearVelocity right?
It is, and honestly it works really well
I am quite happy with the results
I have a question about rotation, may some of you might be able to help. I want to rot a object, by pressing a key, so far it work's. The thing that i don't understand is, i print out the rotation. The print out is 0,45,90,135,...315,0. In the Inspector is the rotation, goes from 135 to -180, why? The Code is ' if (_middelObject)
{
transform.Rotate(Vector3.forward * 45); // and Vector3.back -> for the other direction
_selectionManager.middelRotation = (int)transform.rotation.eulerAngles.z; //This is the "printout"
}' H
that's how angle normalization goes sometimes
unity goes -180 to 180 to keep the value small in the inspector
generally, don't read eulerAngles, treat them as writeonly
understood, and now how to get the correct value in the selectionManager _selectionManager.middelRotation = (int)transform.rotation.eulerAngles.z; ?
what do you mean "correct value"
They're both correct, unity just normalizes it in the inspector
its the same value, just displayed differently
if you want to display it as unity does in inspector you just do the normalization yourself
float z = transform.eulerAngles.z;
if (z > 180f)
z -= 360f;```
i'm using a if statement later and the statement don't work
thats an entire different issue than what you're asking
something like if middleRoation is 270 do XY
ok so what code do you have now and whats isn't working about it
switch ((middle, right, left))
{
case (0, 90, 270):
letterIndex = 1;
Debug.Log("Case 1");
break;
case (180, 90, 270):
letterIndex = 1;
Debug.Log("Case 2");
break;
something like this
What if statement and what is "doesn't work"?
Maybe just store the rotation in an integer (0,1,2,3) or enum instead of looking for exact floating point number match
I try the normalising option, or that idea seems more pratical
Thank's
@limpid sparrow how many chases do you expect ? it may be cleaner to use a lookup table
Theres also a one-liner way of doing this z = Mathf.DeltaAngle(0, z)
Wraps it to the -180..180 range
Though it might be confusing for some
oh nice.. TIL 
one for each letter of the alphabet
i will google it, thanks
I'd probably round the float instead of truncate though
do you really want 9.9 to be 9 instead of 10 ?
i didn't use float, i'm using int's for. The Rotation doesn't need a decimal point
I understand but you're doing (int) myfloat this will "truncate" the decimal
so I said in the example 9.9 would become 9 but you might want it to be 10 so its best to do a
int myInt = Mathf.RoundToInt(myfloat)
understood, i know what you mean now
Hi all, I'm having a bit of a brainfart and hope someone can help out a little.
I have this code as part of my character controller (using addforce to control everything).
private void MovePlayer()
{
// Let's try this shit
Vector3 moveDirection = transform.TransformDirection(smoothInput).normalized;
if (targetForward == 0 && targetRight == 0 && playerRigidBody.linearVelocity.magnitude > 0)
{
playerRigidBody.AddForce(-moveDirection * playerMoveSpeed, ForceMode.Acceleration);
}
else
{
playerRigidBody.AddForce(moveDirection * playerMoveSpeed, ForceMode.Acceleration);
}
}
Everything works great, except the stopping. lol. As you can see I'm trying to apply an 'Opposite' force to bring my character to a stop (increasing the drag doesn't really work unfortunately, kinda makes the character behave as though it's in clay).
Using the code above the force applied to the character does change direction correctly, however the character kinda flies off the screen.
Not entirely sure what I'm doing wrong, but there's obviously something wrong in my logic. (targetForward & targetRight are set between 0 and 1 with the WASD keys).
Could someone point me in the correct direction please? ๐
This isn't enough code.
But I don't see anything in this code adding an "opposite" force to slow anyone down
playerRigidBody.AddForce(-moveDirection * playerMoveSpeed, ForceMode.Acceleration);```
This is adding a force opposite your *input direction* not opposite the current direction of motion
and if the input is 0, it's doing nothing, because -0 is still 0
It's also unclear what targetRight and targetForward are or where they're being populated
Oh yeah. eesh. Sorry, long day. Gimme a sec.
This is the complete script. There's a lot going on so it's a bit long, sorry ๐
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Guys should I do health regeneration in Update() or FixedUpdate()?
Could someone tell me which one works the best?
do you want it every frame or physics step?
or maybe per some arbitrary amount of time?
even with this route, you'd have to choose whether to update it on frames or physics ticks
yeah youre right actually i missunderstood what nav said
he was just comparing the 2 updates lol
hey guys, I'm very inexperienced with tilemaps, is there a way I can make a script/shader that makes tiles gradually darker the further away they are from an "edge" of the tile (visual mockup in photoshop)
What I had initially on my mind is setting a script that can check my Tilemap/Tilemap Renderer components and assign a value of "Depth" to each tile (edge tile = 0, and every tile away from an edge is +1), and then depending on their depth, change their color multiplier to different shades of black
Is this something that can be done with tilemaps? Or will it be best to spend my time just making the extra few sprites of darkened terrain?
I used normal update, so I will just leave it like that
if its increasing across frames make sure to * Time.deltaTime otherwise different framerates will affect the speed (eg high fps = increases faster)
also if you're doing it in discrete steps, have an time accumulator and use loops to make sure it stays consistent over time
Just checking but Rigidbody.linearVelocity is world space and not local right? And if so how can I get the local space velocity?
you can use transform.InverseTransformDirection
For what?
to convert it from world space to local
PlayerRB.transform.InverseTransformDirection(PlayerRB.linearVelocity).x like this?
Vector3 worldVelocity = rb.linearVelocity;
Vector3 localVelocity = transform.InverseTransformDirection(worldVelocity);
Okay so mine is just shorter?
yes if you just need the lateral velocity use .x
also you dont need .transform
Ohh okay thanks
looked in code general and couldnt find any thred with AI vision or detection system.
huh?
Wouldn't this be #1202574086115557446 or #๐คโai-navigation
fr lol
really depends on what ai vision / detection means
im assuming just pathfinding with player detection
single cast ray wont work. then it will be same as in half life 2. 1 small item can block vision
could cast to multiple points
i dont think thats how half life 2 handles player detection?
half life 2 has pretty advanced ai for its time
idk, i was looking in google and found guy talking how holding single can make them invisible
this isn't really an answer to what i said
you'd have to give proper context to what your looking for here otherwise people will just kinda vaguely guess what it is which might not allign with what you want
player detection for enemy. what else to add?
this is more #๐คโai-navigation than anything then
i could cast 5 rays (4 for edges and 1 in center)
or make a thread in #1390346827005431951
that sounds like a good start
I think some games have like points per limb?
its very inactive about AI topics, because ai-navigation exists
one from the center mass and one from the head
like if its a rigged enemy you'd get the center of each leg, the body, the head etc.
right... then you use #๐คโai-navigation lol
might be overkill for every single limb though
might be! that's why proper context on the question is important ๐
but thenn enemy wont shoot, if players half body is exposed or feet are sticking out belove table
how you would phrase it?
it's less about phrasing and more about giving people the information you already have
at some point would a vision cone be more reasonable if you want the smallest part peeking to count as a detection
think about all the questions we have asked you and all the respones youve posted,
in theory you probably could have gotten to this point in the conversation from 1 initial message that contained the thoughts and concerns you've already mentioned
its not like a big deal but it helps you get your answer faster and us understand it faster
it would be logical solution, but then how to acomplish it?
well it depends, do you want to punish your players if their feet are slightly visible?
this is as much of a design decision as it is a technical one
most detection systems give the player a lot of lee way
because it just feels less punishing
doing shooter game (CQB). it should punish for player exposing.
thats not what i asked though
or if yknow, a sleeve peeks behind a wall because of it being impossible to judge or control that within a game where input fidelty and depth perception are limited
thats why games purposefully make detection for enemies "worse"
theres a difference between the player standing out in the open vs a small part of them peeking through cover
you dont want to punish the player for the latter
or you shouldnt, do whatever you want
Casting to limbs should be the best solution, i guess. doesnt pusinh player too much, but also doesnt ignore big parts exposing.
imo you should cast from enemy limbs to your players center mass... and maybe the head
casting to individual player limbs is exactly what you want to avoid
i intend to add small points of last player seen position, it wouldnt allow player to repeak angle same way
max ray cast would be 6. (2 legs, 2 arms, head and torso)
its your game, but this is exactly what we are telling you to avoid... casting too individual legs and arms could be too punishing, feel free to test it and play around with it
seems like a #1062393052863414313 question?
posted there
best question would be how much ray would be too much. Ray are expensive?
rays are cheap
my grenade system uses up to 40+ rays for occlusion
theres also close to a hundred raycasts in certain update functions
no performance impact, so go crazy
it's using the fancy raycastcommand stuff but this dispersing prop step in my world gen does a millie raycasts lol
raycasts cheap cheap
then my crazy idea can work
Can someone explain what's wrong with my code?
ah thanks
if you read the full desc you can probably figure out how to use that value https://docs.unity3d.com/6000.4/Documentation/ScriptReference/Input.GetAxis.html
you probably want to GetButton instead, no?
an axis is an analog input
(the logic is kinda questionable though)
what is the diffrence?
it's treated as a button when you call GetButton
GetButton is for buttons while GetAxis is for axes
So i should use GetButton?
if your Fire1 input is a discrete button rather than an analog axis, yes
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.
Hi, I'm new to Unity and C Sharp and could you please check if everything is ok with my object generation script?
you tell us, what's the issue you're having?
!ask not if you don't ask ๐
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #๐โfind-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #๐ฑโstart-here
that would be a #๐ปโunity-talk question
I'm just not sure if I wrote the procedural generation script correctly
does it work?
https://pastebin.com/5jT2zHXu
I'm sorry, it was a different code.
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.
is it working?
Yes
then what do you want us to do lol
Well, I just don't know how to write good code, so I thought maybe I wrote it badly
it works though... unless you see something explicitly wrong with the way it works
you dont have to worry about it
oh, ok
Im trying to make a turn based strategy game and want to use hexes for the (3d) map. My problem is that the Asset that im using has a wrong center and I dont know how to allign the hexes. (I dont know the Dimensions either). Should I make my own basic asset, use rectangels, do it in 2 d or use an other asset? Thank you.
What asset?
Unity has a grid component that supports hexagons
Its a Hexagon
A texture?
You can see its dimensions in unity if you select the texture, or in your OS file browser
Oh 3D mesh?
its a prefab
my idea was to make a grid of game objects and teleport the Pieces to the center of the game objects
Are you using the grid component, if not, you probably should
https://docs.unity3d.com/6000.4/Documentation/ScriptReference/Grid.html
For example GetCellCenterWorld would be useful for placing objects on the cells
Im not using it reading about it now thnx
Hello. Are there any Codewars users here? I'd love to add some allies
no
When compiling my game or using playmode my variable change( well this is my hypothesis). My code is this:
Vector3 worldVelocity = PlayerRB.linearVelocity;
Vector3 localVelocity = this.gameObject.transform.InverseTransformDirection(worldVelocity);
// Movement direction (camera-relative)
Vector3 moveDirection =
(this.gameObject.transform.right * CurrentMovementInput.x +
this.gameObject.transform.forward * CurrentMovementInput.y) * MoveSpeed;
if (moveDirection.magnitude > 1f)
moveDirection.Normalize();
// Jump
if (groundedCheck.isGrounded && JumpIsPressed)
{
JumpIsPressed = false;
PlayerRB.AddForce(Vector3.up * 391.65f, ForceMode.Impulse); // simplified + tunable
}
// Target velocity
Vector3 targetVelocity = moveDirection * maxSpeed;
// Convert target velocity to local space for comparison
Vector3 targetLocalVelocity = this.gameObject.transform.InverseTransformDirection(targetVelocity);
// Calculate velocity difference
Vector3 velocityChange = new Vector3(
targetLocalVelocity.x - localVelocity.x,
0,
targetLocalVelocity.z - localVelocity.z
);
// Apply movement force
PlayerRB.AddForce(this.gameObject.transform.TransformDirection(velocityChange), ForceMode.VelocityChange);
// Friction / stopping
if (CurrentMovementInput == Vector2.zero && groundedCheck.isGrounded)
{
Vector3 horizontalVelocity = new Vector3(worldVelocity.x, 0, worldVelocity.z);
PlayerRB.AddForce(-horizontalVelocity * 0.1f, ForceMode.VelocityChange);
}
``` IT works fine in the editor, unity 6.4 and this is all called in update.
you don't need this or gameObject for most of this btw
you can just access transform directly
Oh I know I just use them because of habit
I don't even know when I began to do that lol
js moment
Okay turns out this isn't variables changing. But my when I move in a compiled game it goes CRAZY. I am using FishNetworkin. I wonder if thats it.
Like my Velocity is the maxium possible value
you should only add force in FixedUpdate
thats a question for wherever people talk about fish net
Yeah I was thinking that
I'll go to their server
This is probably due to higher framerate in the build so it just adds even more force
but it is so dead lol
Hmmm okay
Wait I have a way to test this
OMG IT IS, THANK YOU. I have actually been going crazy with this since yesterdayyyyyy. I cannot thank you enough
I can tell lmaooo
actually since the day before yesterday.
You also somehow missed learning about delta time and how we can use this to make things "framerate independant"
https://docs.unity3d.com/6000.4/Documentation/ScriptReference/Time-deltaTime.html
How to alter physics and using delta time/frame time is a common topic for game development/realtime 3d applications
I learned it, but just incorrectly i guess
It's hard enough trying to learn code itself
but when you cant even use visual studio without it messing up it makes it even more stressful. I cant get it to so suggestions at all when im typing stuff. Im using 2026 and I updated it. Ive already got .net and stuff installed. I tried many different solutions and none worked...
Can someone please help me fix it I can screenshare if I need too
theres no screensharing here sorry
make sure you've gone through this if you haven't gone through it all
!ide
If your IDE is not autocompleting code or underlining errors, please configure it.
Select one:
โข
Visual Studio (Installed via Unity Hub)
โข
Visual Studio (Installed manually)
โข
VS Code
โข
JetBrains Rider
โข :question: Other/None
^ once you follow these steps make sure you close VS and let unity open it to edit a script (so it opens correctly)
Assets > Open C# Project / double click a script asset in editor
if i do something like public or public int it autofills it
but if im doing oncollisonenter or
getcomponent I dont get shit
I read through all of that stuff
If the unity tools were installed it should suggest unity message names ๐ค
but technically they work in a non standard way so they dont "appear" by normal c# rules (unity calls em by magic)
Hi! It is me again lol, but anyways. When I rotate an object, but it's rotates around a pivot, my method doesn't move the Object to the target's new position.
void MoveTowardsTarget(Rigidbody Object, Transform target, float force)
{
Vector3 pendingForce;
Vector3 direction = (target.position - Object.position);
pendingForce = direction * force;
Object.linearVelocity = pendingForce * Time.deltaTime;
}
Do people actually install Visual Studio through Unity Hub?
no cus its an old ass version
Fair lol
you can combine the pendingForce declaration with the assignment; no need to separate it. Object isn't the best name for a variable, because Unity has their own Object class, and it doesn't describe what the variable is: a Rigidbody. Lastly, you do not multiply velocity by deltaTime . . .
Quick question, what's MonoBehavior and why would we not want to have scripts derive from it?
lmao i had the 2019 version until just a few months ago
but we do (derive from it). A large portion of your scripts will indeed derive from MonoBehaviour because that's how you create components to attach to your GameObjects . . .
Any idea why raycasts are being so buggy? I am walking into the object it doesn't detect but if I jump onto it it detects fine...
๐ Large Code Blocks
Use links to services like:
https://pastes.dev/
https://paste.yunohost.org/
https://share.sidia.net/
https://paste.ofcode.org/
https://paste.myst.rs/
๐ Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
some prior terms first:
UnityEngine.Objectis anything that the Unity engine can keep track ofComponentis anything that you can attach to aGameObjectBehaviouris aComponentthat you can enable and disableMonoBehaviouris aBehaviour, and user scripts are allowed to inherit from this class
the real question is knowing when to derive from it or to use a plain 'ol c# class (POCO) . . .
The name itself is a bit of a legacy thing โ I believe it refers to the Mono runtime (the system that actually runs your C# code)
ah, i see
You inherit from it to create new kinds of components
If you are not creating a kind of component, then you need to derive from something else (or nothing at all)
e.g. ScriptableObject to create new kinds of generic Unity objects
Understanding object oriented programming should explain it anyway
you gotta read this again ๐
and we'd need to see where your using the stuff in this helper class
mote the Mono in MonoBehaviour. it's intended use is for a single behavior . . .
that is not why it is called that lol
float castDistance = HipHeight + 2f;
Vector3 groundOrigin = Character.position + Vector3.up;
Vector3 leftLegPos = Character.position - (Character.right * 0.5f);
Vector3 rightLegPos = Character.position + (Character.right * 0.5f);
float legCastDist = Crouching ? 1f : 2f;
Vector3 legBoxSize = new Vector3(0.75f, Crouching ? 1f :2f, 0.75f);
Vector3 VectorDown = new Vector3(0f,Crouching ? -1f : 0f,0f);
var leftHit = Eggie.Boxcast(leftLegPos+ VectorDown, legBoxSize, Vector3.down * legCastDist, Character.rotation, GroundLayers);
var rightHit = Eggie.Boxcast(rightLegPos, legBoxSize, Vector3.down * legCastDist, Character.rotation, GroundLayers);
var leftHitRay = Eggie.Raycast(leftLegPos,VectorDown*legBoxSize.y,rParams);
float FloorPlantLevel = -2000f;
List <float> YLevels = new List<float>();
if (leftHit.Hit) {
Debug.Log("Left:"+leftHit.Instance.name);
YLevels.Add(leftHit.Position.y);
}
if (rightHit.Hit) {
Debug.Log("Right:"+rightHit.Instance.name);
YLevels.Add(rightHit.Position.y);
}
foreach (float Value in YLevels)
{
if (Value > FloorPlantLevel) FloorPlantLevel = Value;
}
isGrounded = FloorPlantLevel != -2000f;
// Stair sticking
bool stickToStairs = false;
if (!isGrounded && Velocity.y <= 0)
{
var stairStick = Eggie.Boxcast(Character.position+ VectorDown, legBoxSize, Vector3.down * legCastDist, Character.rotation, GroundLayers);
if (stairStick.Hit)
{
Debug.Log("Stairstick:"+stairStick.Instance.name);
isGrounded = true;
LastWall = null;
FloorPlantLevel = stairStick.Position.y;
stickToStairs = true;
}
}
we're changing the game over here, okay . . .
im leaving monobehaviours behind entirely ๐
scriptableobject singletons and poco classes my beloved
its a shit old name and nothing more
See it works fine for ground and stuff, but on wedged mesh parts it completely breaks
mono means one
and behaviour means behaviour
๐คฆ
its a simpsons reference ๐
facts. these are my ride-or-die . . .
See it only detects the hit if I am landing on it.
Where's the damn StereoBehaviour??
But the first two left and right hits should also be factored and they arent for some odd reason
i wasn't sure on what to name the double behavior . . .
CoreCLRBehaviour ๐
i'm not sure what you mean by "first two left and right hits" -- are you takling about the boxcasts?
small thing: your boxcasts are inconsistent; the right leg doesn't add VectorDown
but that only matters while you're crouching
Yes
But even if the right doesn't hit the left one should be but doesn't detect it
It's skipping the wedge and hitting the ground under
The only time it actually detects the wedge is if I am jumping stright on top of it
if a BoxCast starts inside of another collider, it will ignore that collider
That would explain why it works when you jump
So how would I solve this issue?
If a wedge can be higher than player
In terms of like map designing and such
Cause I want to have some walls that are angled
or like angled floors
i'm guessing that the boxcasts are starting low enough that, when you walk directly into a sloped surface, they start inside of the surface
and thus don't detect it
raise them up a bit and see how it behaves
yeah and if I am walking onto one it skips it
plus theres an issue where I need to be able to crouch inside vents with slopes and i am using wedges as elevations
if you only need one or the first hit, then using an array of size 1 is unnecessary . . .
okay
Is there a way to make it so unity can detect objects if you start raycasting, since my object uses a custom collider?
Like here the green boxes are the debuggers for the boxcast. but they are outside of that wedge when they start so they should be hitting that wedge, instead they are going through it. and the player is only so big, so having to raycast high in the sky just to detect a wedge under the player sound a bit overkill, plus some elevations are drastically bigger than the player.
@grizzled steppe Seems like you asked in 3 different channels... dont cross-post
You have a thread, don't cross-post here
im trying to implement perlin noise with terrain trees but they wont appear for some reason(?) im not sure what im doing wrong
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.
Time for some debugging then. Find out which part of it is not working
well i am trying that, id prefer if anyone has resources on [procedurally creating tree instances] because i think my problem is i cant find anything that covers it well and terrain is new to me
I was sent back from ai-navigation, but now I have question collider. Is there way to make truncated pyramid collider?
Maybe it's possible to write class
Or shouldn't bother with that and do mesh collider
i don't think you can
To be fair sad that we are limited with square and sphear
(and meshes)
(and capsules)
More than once I wished I could have a cylinder collider tbf
Although, if by "truncated pyramid" you mean a frustum, you could do it manually using GeometryUtility
!collab and English only server
:loudspeaker: Collaborating and Job Posting
We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
โข ** Collaboration & Jobs**
I have a List<Int2> that represents tile coordinates in relation to an object. I wish to rotate these by 90*; any easy way?
Do you mean vector 2 int? But yes you can rotate vectors around 0,0,0 using Quaternions
if you want to get new structs that are rotated, then loop through and rotate them
for 90ยฐ it's just a swizzle and negate one of them
Huh til that's a thing
yeah makes sense
didnt want to use quats because idk floating point and floortoint or smt seems inviting trouble
yeah quite a few primitive transforms can be done with a combination of negate and swizzle (eg reflect on X, reflect on Y, reflect on y=x, rotate 90ยฐ, rotate 180ยฐ)
Is there a mistake in my code ? "Clicked" get's print out twice public void LeftMouseClick(InputAction.CallbackContext context) { if (context.performed && clickable) { Debug.Log("clicked"); _renderer.material.color = Color.green; ClickFunction(); // the first line in this function is clickable = false } }
ClickFunction probably also has a Debug.Log("clicked")
Nop private void ClickFunction() { clickable = false; StartCoroutine(DeactivationTime()); } public IEnumerator DeactivationTime() { Debug.Log("Deactivation started"); clickable = false; for (int i = 0; i < 30; i++) { yield return new WaitForEndOfFrame(); } Deactivate(true); }
The fact that "deactivation started" is only printed once, makes me think this is a different "clicked"..? Can you show the call stack of both?
If i'm understand that corret, the clickable get set to false and still get trigger again, that's got me puzzeled
found the mistake, the script was attached twice. My fault, upps
is there not somethign like context wasPerformedthisFrame for single click
This shows the problem better. The highlighted object is the grabber. The object being grabbed is not parented to the grabber or the player in anyway
The grabber rotates around a pviot, and I don't think that is updating the position
Yep it isn't being updated(the grabbers position)
Would a message queue for the server processing interaction events on the terrain be overkill?
I'm thinking for things like chest updates and other interactions it would make sense for consistency
Move it to #1179447338188673034 , please
It is? For now I have just made so it teleports to grabbers position. And it works well except for the clipping(obviously)
Hello Guys
Howdy everyone
I'm working on toollips for my ability selection menu.
Basically I have a square icon representing an ability you can use (just a button), when the mouse is over it i want a box to show up and show you the name and description.
I'm already using a detection system per button system to display a selection outline for each button, so I was thinking to just call the toolip to spawn with that?
How do people normally add toolips?
why is "color" not working - Cannot resolve symble"color". i already using a KI, doen't helped. There isn't a typo, right? the private Image is Internal class
using UnityEngine.UI; is grayed out which indicates that you are not using the Image type from that namespace
Because tabImages is an array
you can't do .color on an array
also that
you need a specific Image from the array, then you can do .color on it
Box's concern is also true - you probably made your own Image class
private UnityEngine.UI.Image tabImages; okay this works
yeah but you still should choose another name for your class
yeah either never name your types the same as a unity type, or make sure it's in a namespace so it forces you to fully qualify it or you get an ambiguous reference error
you can use a small ui image that you enable and disable when you hover ove rthe buttons
importantly, tooltips need to:
- appear on top of most other UI elements
- not participate in automatic UI layout
assuming you're using UGUI, you'll want to put your tooltip prefab at the very bottom of the UI hierarchy and give it a Layout Element set to ignore layout
if this is UIToolkit, use an absolute-positioned element
I have a quick (weird) question about vectors.
Doesn't it bother you that the direction of movement (normalized) and a regular vector(with distance) are indistinguishable, and you have to specify, for example, in the summary that you want a normalized vector and not a regular vector as input to a method?
Or am I an idiot and it is possible to understand from the principle what exactly the method requires?
what differentiates a float that's an absolute value vs a float that's a delta?
or a float that's in time vs a float for a distance
don't rely on just the types to determine what the value represents
You could, indeed, use the type system to distinguish these concepts
it would be very awkward, though, since many operations make sense for both "types"
the types show how the value can be encoded, but semantics (and documenting those semantics) are also important
it's the same idea as using separate types for "sanitized" strings and "unsafe" strings
This is why functions have (or should have) documentation and/or self-documenting names
e.g. it's why you call your parameter playerPosition or playerForwardDirection not playerVector
i kind of wish it was just float3 instead of Vector3
(like it is in the Mathematics package)
that makes it clear that the type simply represents 3 floats
it doesn't hint at a particular meaning
(of course, in computer science, "Vector" has a meaning totally divorced from the mathematical idea of a "Vector")
that makes it clear that the type simply represents 3 floats
i mean it kinda doesn't, given that it has all the normalization/magnitude/dot/cross stuff
they aren't totally divorced, but the common semantic narrowing is different (and differs in context, not just cs vs math)
Vector2/Vector3 in unity are math vectors (whereas Vectorโ in java or vector in c++ would be the cs vector you're referring to)
Anyone think they can help me? I'm trying to make it so that when my player finishes their jumping animation their capsule collider returns to the normal size it has before it jumps
I have this script that plays when a certain frame of the animation is hit and it returns to running, however I can't seem to access my players capsule collider there
show us what you've done
if you have a component that responds to an animation event, then you can give it a CharacterController field and assign it in the inspector
returnToRun is the function that is called when the animation hits the key
what's stopping you from updating the character controller right now?
I haven't used that before