#💻┃code-beginner
1 messages · Page 258 of 1
wait i´ve just went thru the first line xD
can i see a bit of your game?
your code looks clean (atleast compared to mine)
its very work in progress rn lol
it looks very bad but im just focusing on systems right now
i like to look at basic plane cubes move
my game is made of prefab sprites from unity
heres a picture of some gameplay lol
is it a vampire survivor type game ?
so an rpg it is?
yes
looks cool asf
it depends
compared with a AAA game of course
but compared to others guys first game
yeah maybe lol
we'll see how it turns out
only been working on it for the past 2 months
got a long way to go
you too
send some screenshots
alright
i want to show you the variety of how my system works
if i give the system 17 coins
those are the enemies
and if i give it 57 coins
67*
but it looks better in a video since it is visible how they start stacking
first 2d game do i make project with 2D or 2D SRP?
so is it not working how you want right now?
yes it is
im pretty happy with the results
and if i dont like something i can change it with the variables
nice
imma try to record how it looks
the game is not supposed to have that much enemies thats why the lack of variety
(im working on 2 more )
wait wrong video
this is the one
i am doing it with 2d and a friend is making it with 2d SRP and i cant find a big difference for a begginer
nice looks cool, like a bullet hell
its just the renderer that is used
I don't understand this error can someone please help me
my enemy is moving but it's not shooting fire ball when the player is in range
i get the thing saying paremeter is not set
stack trace is nice, but code would help
okay
oh it's the animator
sorry?
animator does a string lookup and you're giving a value that does not exist in the animator
i'll share the ss just a min
it's less of a code issue and more of you not setting your animation tree up correctly
or perhaps feeding it the wrong string value
right
what should i do here?
w/e range attack trigger should correlate to
whatever
Are you following a tutorials?
yes
You have a variable inside of your animator called explode which is the problem, so go back to the part where you set that and follow it through.
i even checked comments and it's not helping i rechecked the whole clip too
okay thankyou so much
I'm stumped: I've got a method on a button object that is being executed twice
I've tried using the debuggerer, but it just confirms that the method is finding an object twice on me
anyone like to look at spaghetti?
I'll take that as an "I'm full, thanks" XD
Don't ask if someone's available to look at the code. Just provide the code, hierarchy, inspector data and console logs.
Someone who is idling on the channel and only every now and then glances what's going on is unlikely to answer your "asking to ask" question, but your actual problem description may pique their interest and get them to answer.
watching a tutorial and in his vscode some words autocomplete and are highlighted while in mine they arent how do i set this up
Configure your !ide to get proper intellisense
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
• VS Code
• JetBrains Rider
• Other/None
thx
#metoo
so I figured out from the debugger that for some reason after applying all my code the object returns to a null state
it's a proper quandry...
..but I think I've had enough for tonight...
isnt it meant to say samples in that blank box next to walk left
WHy wont this get detected in this script
The object with the script has trigger collider, no rb
the object that wont get collided with currently doesnt have trigger collider, but i tried that and nothing happened.
Full script: https://gdl.space/nexasuquqa.cs
with this script, after the AI stops chasing and goes into the patrol state; i have set his speed in the Patrol(); function to 1.5f however it just stays at 3.5 as it was set in the slowdownchump coroutine idk why
main ai - https://gdl.space/marihudele.cs
the los script sets the patrol and chase functions
Do you mean one object has collider that is checked in trigger other one has only Rigidbody?
@timber tide I fixed the error for fireball but now i am getting that the explode parameter does not exist ( for explode the fireball explodes when it touches any surface)
no both have colliders, one of em is trigger.
And only one has rb (tho i tried with two, even tho that wouldnt make a difference i dont think)
Which one has collider that is checked in trigger?
Well, you got two animations in your tree there, so explode must have been the other one. Seems like you start the first with the RangeAttack trigger, then call Explode animation when the fireball hits.
the one that has the script
Attach the script to the object that has Rigidboday.
well, here is how its set up:
I have a parry hitbox, trigger hitbox, that has that script.
It is supposed to detect parryable objects and put them in a list.
Thats what the script does
Please try like this.
Attach script to trigger hitbox and add Rigidbody to the one.
i tried that, did not work (when giving both Rigidbody)
Not both.
Only one need to have Rigidbody.
Show us the rigid body component and collider
i tried that too, also didnt work
the parry hitbox
Where's the collider?
the parried (but wont get parried which is the problem)
i keep getting errors that go against one another ffs
Turns out the error was in code i fixed it and it is working well now thankyou so much
anf this is the collider for this one
Bro what the hell
Now, how are you moving?
how is this possible guys
If i do one thing i get the error
and if i fix the error i get the other
You cannot assign the quaternion rotation a vector 3. It's expecting a quaternion.
what are you on about
i know
eulerAngles
are Vector3 angles
degrees
rotation is a Quaternion
i DID that
different script, https://gdl.space/alezijazes.cpp
for the parry hitbox
rotation = Quaternion.Euler(...);```
based on players position (a 3rd object unrelated to this)
Vector3 dir = transform.eulerAngles;
Quaternion dir = transform.rotation;
i do this
wait no
im confusing myself nor r u helping rn lmao
Your original image showed you trying to assign a quaternion the result from a vector 3 smooth damp.
I was trying to use eulerAngles
since its a vector 3
then it told me about converting it to quaternion
which isnt correct since it takes vector3s
Then convert from one to another.
I DID
You need to move with rigid body physics (force, velocity etc) to properly acquire physics messages.
That's illegal
You cannot assign a quaternion the value of a vector 3
rotation is not a vector 3
huhhh?
but... it works with a different projectile... and has worked before (but i didnt save properly and now when i try to redo everything it doesnt work)
with the current set up i cant move it with physics its just not effecient in my situation i dont think
bump
You cannot assign a quaternion the value of a vector 3cs transform.rotation = Vector...//illegal
that isnt correct
stop repeating urself ffs
i know
Im trying to relearn c# currently, is there a vid someone can send me on animation thru unity
!learn will have tutorials
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
I dont know how im supposed to smoothly turn my player to the direction it walks now because this clearly isnt working
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Moving with the transform component is teleporting and ignores physics interaction. You'd be lucky if any messages were acquired - if something was simulated thereafter it might trigger some physics messages.
Consider using rb move position if you aren't necessarily wanting to teleport
can you elaborate more on the rb move position
If you've got a rigid body that's kinematic, you'd use https://docs.unity3d.com/ScriptReference/Rigidbody.MovePosition.html else you'll have to manipulate movement with velocity or forces - I'm assuming it was kinematic but do the other if not.
Or optionally call the expensive https://docs.unity3d.com/ScriptReference/Physics.SyncTransforms.html after teleporting with Transform.
so this helps it not ignore physics interaction that are due to teleporting (btw it wasnt kinetmatic rb)
heyy chat!
so, I have this script here that draws a circle and spawns some things in it.
however, the circle is drawn in the middle of the screen and I want it to be drawn around the object the script is attached to.
how can I pull this off?
Add the object's position to the random calculation: = transform.position + Random.insideUnitCircle * radius;
oo I was thinking it could be that but I wasnt sure.. thank you! ^^
target.position + offset would be what you'd want to pass as an argument for the position of Instantiate.
it still doesnt detect the laser shooter
one small issue--
Probably cast the result from the stuff on the right side of the addition operator to vector 3
Or vice versa
fixed iiit
I love you guys
😔
guys my raycast gets a object only once and proceeds to get the boject behind it also jsut once
You'd probably want to show the !code that's got conflicts
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
Your options are either inline for small snippets or the free services linked for large code blocks.
so should i sedn the script now
Hi guys, I'm new to Unity Coding, coming from Game Design background. I know I want to create ambitious things which I can design quickly on paper, but I have no idea about the complexity of the coding part.
I would like recommendations for learning approach and resource links to get myself started.
Thank you.
I have completed the Roll-A-Ball tutorial btw, that has been a good start for me until now
For the links: you'd paste your code there, save using the button somewhere on the service site and post the updated link here.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Dooropening : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
RaycastHit hit;
if(Physics.Raycast(transform.position, transform.forward, out hit))
{
Debug.Log(hit.transform.name);
OpenDoor Script = hit.transform.GetComponent<OpenDoor>();
if (Script != null)
{
if (Input.GetKeyUp("e"))
{
Script.Interact();
}
}
}
}
}
bum
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Is there a SmoothDamp that works for rotation
or is similar to how smoothdamp works
heyy Im back again! ^^;
same script, this time I wanna destroy the object after spawning a certain amount of rubies but... the object doesnt get destroyed and just keeps spawning them!,
because i really wanna make my player rotate just like it
@ivory bobcat thanks a lot. Which pathway would be best? Junior Programmer?
I am focusing on building basic games, mechanics based and prototypes at best, nothing too complex for now
becaues what you did doesn't make sense
your loop runs untill i <= rubyDropCount
so i > rubyDropCount will never be true
i can never be greater than rubyDropCount because at this point your for loop stops running. If you want to destroy the object after everything has spawned, then move the Destroy after the loop
Without the if statement
moving it afterwards just destroys it after spawning a single ruby
although... brb
It won't, it's just that all of them are spawned at the same position (because you compute the random once)
guys wth is wrong with my code the raycast gets the object behind other object and it gets everything just once and never again
this is happening to me for the first time
oH-
what r u on about
lmao
Take a peak and determine what's necessary for you. The entirety of coding with Unity is vast. Depending on your level of knowledge with code and awareness of Unity, you might be fine skipping some. Maybe try looking at the junior and go from there.
i dont understand what u are tryna say rt at all
your sentence was just
ist complicated
useless to me
damn
i dont understand what ur askingg
gets the object being the other object so ur blacklisting a layer?
They posted their question with context a few minutes ago, scroll up
the variable hit only gets the object once and when i look at it again it just doesent
get it again
only once
Post your console logs. I'm assuming they're collapsed.
lmao
Thanks. I have covered some patterns as well. Btw I am changing from Unreal Blueprint to Unity so I have some idea about doing things, but now how Unity allows it, so I guess knowing the WAYS and syntax is gonna be priority one I guess.
i love you tho
You could always opt for #763499475641172029
Nah, I wanna type things, love the sound of mechanical keys
Thanks, I'll walk the pathway of Junior Programmer then.
yea I think it good if you transitioned from ue, though it takes so long to build with visual enabled/installed
could anyone help me out? my character seems to take a split second before he stops moving https://pastebin.com/0cUXTrHZ
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I use UE for mostly Level Design and stuff
man i jsut read all the messages i jsut sent and oh god the misspleiing in those
You're using Input.GetAxis, which has smoothing applied, so releasing the key it'll take a few tenths of a second to go back to 0. The effect is much more noticeable since you normalize the vector. Use GetAxisRaw for instantaneous changes
pls
Any idea on how to recreate something like this?
"Rapid Roll Nokia" 1110 game. - Built-in game from Nokia 1110!
«Rapid Roll Nokia» Черно-белая игра. - Встроенная игра с телефона Nokia 1110!
#RapidRoll #Nokia #javagames #джаваигры #игра #игран...
Thank you so muuuch
Looks easy enough but I dont see how I can make the side walls move up infinitely
i got entirely ignored lol
maybe just an animation
never done animations before
Is there a SmoothDamp that works for rotation or similar to how SmoothDamp works because i really wanna make my player rotate just like it
A trick would be to not move the two ladders at all, but instead make a texture that repeats, and from a script modify the texture's drawing origin up to simulate movement
Damn
you are smart
those problem solving skills are crazy
anyoneee?
A vertical endless platformer that increments score on vertical movement. Could probably search and mash up a few tutorials.
smooth damp works on vectors or a float value. you can use it for anything . . .
rotation is quaternions
it also look like camera movement and just outside camera view new obstacle being created and destroyed
so i cant
you can: rotate using Vector3, or Quaternion.Euler, and other methods that return a quaternion . . .
i couldnt
i have errors with it alreadyy
so i used some Quaternion thing
and it doesnt work like SmoothDamp
It's a bit more complicated to make though, you need to make a material and put your texture on it, then access that via script. Or go full custom and make a shader that does this out of the box.
The "easiest" solution would be to have two walls on top of each other, and when one goes off screen you teleport it down below the one still on screen.
well, i'd start by fixing the error. at least post and show what you have. you can simulate a smooth damp using slerp/lerp as well. there are many options, but it depends how you move/rotate your object . . .
bro i told my error before
i dont think theres a way to get around it
im using RotateTowards rn
float horizontalInput = Input.GetAxisRaw("Horizontal");
float verticalInput = Input.GetAxisRaw("Vertical");
Vector3 movementForce = ((verticalInput * Vector3.forward) + (horizontalInput * Vector3.right)).normalized * movementSpeed;
movementForce = cameraTransform.TransformDirection(movementForce);
if (movementForce != Vector3.zero)
{
Quaternion toDirection = Quaternion.LookRotation(movementForce, Vector3.up);
transform.rotation = Quaternion.RotateTowards(transform.rotation, toDirection, rotationSpeed * Time.deltaTime);
}
cant u just make many sprites
That's what my last solution does, with 2 per side you scroll up continuously and warp them when they go off screen
As long as each one is bigger than the height of your screen there won't be any issues
hey sorry to bother man, but do you know how I can a 3rd option on these lines? Basically this code is to change the animator when the character idle faces North, the Idle5 is for North East but I'd like to add another option which is North West
if (moveInput.y > 0) { if (Mathf.Abs(moveInput.x) > 0) { anim.Play("Idle5"); } else { anim.Play("Idle4"); }
Scrap that off and use an animator Blend Tree! They're made for this kind of stuff
You pass the input X/Y to the Animator and it decides which animation to play by itself, look it up
Also I would avoid hard coded strings like that. It will make you go crazy.
my concern is that when I add too many animation i'd end up with an animator that looks like this
one thing you can do that might help (since unity will force you into strings) is to define:
private const string IDLE_1 = “Idle1”;
that is spaghetti
oh I have them as so already
Not with a Blend Tree, at least. It's one state, that has multiple sub-states, so nothing like this
Have you considered not just throwing animation states haphazardly and connecting everything to everything?
You have to try to make an animator this convoluted
You have Any State and the ability to make sub-graphs and groupings to keep an animator clean
have you ever played game builder garage?
lemme look up how to use the blend tree thanks guys
imagine a game making program where everything is just a big graph of nodes (like shader graph) for visual scripting.
this is actual code. not mine. but it is a thing
I’ve played it and it’s very annoying to get a clean graph.

i do not know how people get this far, but life finds a way
and it doesn’t have to look like that. people just do
my code for reference
(not trying to flex, just to show the difference for people without context)
sorry one more thing, is there a way to use different blend trees? by that I mean for example you're using a sword, obviously you'd have different animations than with a bow
point being, when you make any sort of graph-based code, you need to be on top of it to keep it organized
because it can easily turn to spaghetti
my blend tree is usually entry -> node -> entry
but ive not really made anything intensive that dark souls
my advice is to use space to keep “blocks of code” together. And try to make it read roughly left-to-right, top-to-bottom
just manipulating the effective “whitespace” and relative placement in 2D will do wonders
digiholic’s code is a good example
unity is messing up the colours on my pixel art sprite and i dont know why? what i did was press import asset, pick the png i just made, change pixels per unit to 16 and change filter mode to point no filter
ok
how do i make
a rigidbody stop moving when it hits another rigidbody
due to gravity
like, if we jump, we stop going down once we hit the ground
thats what i wanna achieve
make sure the rigidbody is not kinematic so it reacts to outside forces like collisions and make sure it has a non-trigger collider
otherwise you'll need to control its velocity manually for collisions
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
Okay, revisiting this one cause the maths is driving me nuts.
This is a small chunk of code to work out Long/Lat values based on my ships position.
The Longitude seems to be working perfectly, but the Latitude calculation is very very wrong (it hits a latitude of 90 almost immediately when moving north/south.
void Update()
{
RaycastHit hit;
// Does the ray intersect any objects excluding the player layer
if (Physics.Raycast(eagleGPSRayEmitter.position, eagleGPSRayEmitter.TransformDirection(-Vector3.up), out hit, Mathf.Infinity, layerMask))
{
eaglePosX = hit.point.x;
eaglePosY = hit.point.y;
eaglePosZ = hit.point.z;
//Debug.Log(hit.point);
}
longitude = (Mathf.Atan2(eaglePosZ, eaglePosX) * Mathf.Rad2Deg) - 90f;
latitude = (float)Mathf.Acos(eaglePosY) * Mathf.Rad2Deg;
// this bit is to flip and quarter rotate the latitude number to put it where you would expect
// (assuming you are an earthling)
// with 0 at the equator, 90 at the north pole and -90 at the south pole
latitude = (latitude - 90f) * -1f;
Debug.Log("current long = " + longitude);
Debug.Log("Current Lat = " + latitude);
}
I'm 99.9% certain it's an issue with using Mathf.Acos but I don't know what else to use to be perfectly honest. Could anyone help please? 😕
Is there a SmoothDamp that works for rotation or similar to how SmoothDamp works because i really wanna make my player rotate just like it
hi chat! ^ -^
so, I have this script here that is supposed to destroy a certain type of object when the player touches it.
however, the object has two trigger colliders. a box collider 2D and a circle collider 2D.
how can I make the object get destroyed only when player touches the box trigger and not the circle trigger?
every
single issue
you have
you are here
chatgpt or online
bro wth
are very normal alternatives
I think Lerp and Slerp are the usual ways to do that.
SmoothDamp is lerp right?
or uses it
-
chat gpt isnt accurate at all
-
this is the CODING HELP chat
-
this is my SECOND time coming here today, and before today was SEVERAL WEEKS ago
first thing: don't compare tags using string equality, use the CompareTag method instead.
second: you probably want to put those colliders on separate child objects so that you can put this code only on the collider you want to affect. otherwise use physics queries instead of relying on trigger messages
so i randomly come back to you here
bro's mad I come to the code help chat to ask for code help
bro wth is your arguement here
argument* 🤓
I always get them mixed up if honest. But yeah I think so.
come back when youre bilingual.
dw i already am
wth is wrong with you anyway
You're just here to stir shit up right? Like yesterday evening
f me I guess for asking for help in an ASKING FOR HELP chat
Go troll somewhere else
they getting mad
just ignore the troll
what kind of toxic troll do you have to be
tf r u on about
ur so angry
just block them and move on. they are intentionally being obnoxious at this point
Not the place dude. And tbh, I've asked more questions than him today.
smfh... 4 chan twitter ass troll.
you are getting angry for no reason
you cant top me for sure
xD
lol
i told you you can use chatgpt or just google
aight, blocked, anyhow
THEN ask
kewk
its not hard to fucking get that in ur head is it
she/her please ^^;
¯_(ツ)_/¯
hey male
Apologies
talking like u got above average testosterone levels
<@&502884371011731486>
Do you have multiple triggers on the same object? If you want to detect which one has been hit, then you can't! You should put them on two different objects
🤓
You know that this is ridiculously simple to answer with Google right?
most people fake block
Then why do you still talk? They can't even see your messages
-
arent CompareTag and the equals method the same?
-
alright lemme try that!
it gave me no good answers
why not
bro straight up must have had a flabbergasting notice from somewhere for acting like this
Because you're just flooding the chat with your nonsense
Pushing questions up
nathan just a question but do you really get something out of this?
alright gotcha... so I gotta put in on a child with a different tag... alright!
do you get anything out of looking at a screen all day and gaming
no, CompareTag actually provides relevant error messages when a tag does not exist, string equality will just return false. but also CompareTag is actually faster! it doesn't have to fetch the tag from native code then compare the strings, it just passes the string you want to compare into native code and does its thing faster there
nope. only entertainment which wastes your time of doing something productive
not reading the messages but lemme guess, did they say YWNBAW yet?
so i dont understand ur question
oo okay okay gotcha!
bro you aint no genie who can see into the future or the past you know nun of what i do in my free time
would there be any benefit in using == for checking tags in any scenario btw?
no
thank you!! ^ .^
im pretty sure you have gamed at a time of your life
Yeah, usually if you need different collisions for different overlapping colliders, it's usually done by creating child objects for each of the colliders with different tags or layers. At least based on what I've seen/know
let me explain this, it might be difficult to understand tho, what do you get from acting like this?
do not feed the troll. just let a mod ban them whenever one comes around
kinda true
love how i get called a troll
No point in arguing with him, ignore him and move along
while a kid gets angry over me telling them some shit
oof, still here hm?
at this point I think that they get off to it lmao.
i just want to know why would he do that, just genuine concern for him, maybe he is going thru shit idk
how dare this man woman know my secrets
absence of parental figures
Enough with the off-topic
just ban em honestly
😔
So....anyway. lol.
fr, the blatant transphobia should be enough for a ban
hi caesar!
the fuck did you get that from
Still catching up
Sure, but probably not here
I don't understand how default positions are assigned in Unity. The white gizmo is the BoxRegion script I made, and I don't understand what caused it to be so far out.
for one you got handles* assigned to center instead of by pivot, so that may cause some confusion for where you may think it should spawn
can i dm?
i love how this started over a missunderstanding 💀
Sure
I thought they were here throughout the day asking
but its just the fact they spawned in at the exact same time as me
!ban save 680496323882909706 Off-topic spam, transphobic comments.
the fuck
the timing on that xD
🤣
wait damn I called it
what is ywnbaw?
"you will never be a woman", something transphobes tell trans people.
anyhow, to get back on topic...
ohhhh
so, CompareTag is better than .tag ==, right?
Yes, much much
yes because it is a bit faster but mostly because it provides relevant error messages
Does anyone have a 4 way movement script for a 2d game I have been trying to make one for like a week with my horrible coding skills and nothing has worked
there are plenty of tutorials for that
I have a simple one! ^ -^
but I advise you learn how to write it since that level of math is essential for gamedev
Loads of tutorials about. Best to try and find one that explains what's happening and why too.
K thank you!
A lot of tutorials just go through and tell you what to type without explaining why and what each line of code is actually doing.
a 4 way movement system would be a great thing to start learning unity tbh. you learn
-
components, as well as a very essential component (
rigidbody) -
physics
-
inputs
aanyhow... I should have dinner now. byee chat!! uwu
honestly, I kinda need to just find some sort of tutorial on how positioning works in Unity, since I have no idea how the initial position of the box was assigned in the first place. Right now I know almost nothing about pivots, handles, etc.
set the tool handle in the upper left of the scene view to Pivot instead of Center so you can see where the object you have selected is actually at. right now you are seeing the approximate center of the object and all of its children
ah
ooh i had no idea there was a shortcut for that
also from the screenshot the object selected is a child to another object, so positioning you are doing will be relative to the parent
i randomly push it by accident and thus wind up in Awful Center Mode
though, I'm still confused as to how the gizmo ended up out so far.
When I invoke an event, can I pass a variable from it to any listeners somehow?
that's where the actual center of the selected object is. notice how in your capsule collider you've set the center of the collider so far out on the Z axis?
yes, pass it to the Invoke method as a parameter
you'll need to change the type of the event, of course
System.Action<int> to pass an integer
or UnityEvent<int> if using unity events
this part makes sense, it's the white box throwing me off.
The capsule collider is offset by a large distance on the Z axis and the box is offset by a small amount on the Y axis
somehow it managed to perfectly center itself on an unrelated object
yes, the object's local position is [0, 0, 0]
so it's probably going to be "centered" on something else
notably, on its parent, Catapults
that's literally the same position as the object you showed before so it is on the pivot of catapults
Why do you say that? It exactly aligns with the pivot of Catapults.
im currently randomly generating those platforms
but how can I make them not generate on top of each other
I mean the small white box
Catapults' position isn't [0, 0, 0], sure -- that just means that it has been repositioned relative to its own parent
like, a new platform will never be above the currently highest platform
This thing?
yes
nvm its easy
I don't know what that is.
ignore my question
that's the gizmo being drawn by the Box Region script on Catapult (0)
What's the box region code?
well, that's your own code. it can draw whatever it wants
you should show us the code for this component
are you certain the gizmo is being drawn correctly
notably, you may be drawing it in the wrong space (world space vs. a specific transform's local space)
or you could be calculating it wrongly, or many other things
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
This is working in world space
If every BoxRegion component has the same size and center values, every component is going to draw the gizmo in the s ame spot
they're also all going to be doing the physics queries at the same spot
The position of the game object that BoxRegion is on will not matter at all.
Okay I think I know what's happening with that, you're drawing it in world space (with your public Vector3s), so it's not referencing the parent object.
I think you should be grabbing the position of the object you want the gizmo to be attached to and use that objects position with an offset on the Z axis so that it 'moves' the box to the center of its parent object.
The correct approach is to transform both center and size from local space to world space, and then use those transformed values. You'd also need to combine your own transform.rotation with direction to correct apply your rotation.
That way, center will mean "the position in my own local space" -- so as the object moves, the resulting world-space position also moves
transform.TransformPoint and TransformDirection are going to be useful here (for the physics queries)
TransformVector for size if you want your scale to matter
although...i'm not sure how that'll play with rotation
as long as there is no non-uniformly scaled parent, it ought to behave well
Vector3 WorldCenter => transform.TransformPoint(center);
Vector3 WorldSize => transform.TransformVector(size);
Quaternion WorldRotation => transform.rotation * direction;
Those should do the trick.
can probably set the Gizmos.matrix to the transform's localToWorldMatrix for the gizmo to draw correctly
yeah, although that doesn't help you do the physics queries properly
i'd want the gizmos to exactly match what i'm actually using
oh, right -- you need to modify the matrix to rotate the gizmo, don't you
yep
that's an annoying x-factor
unless you draw it manually which is a whole other beast
This might be a stupid question, but what are the gizmos being used for?
As far as I was aware gizmos are an editor only thing or am I being an idiot? lol.
they are, but this code is performing physics queries and the gizmos are likely to show where that is happening
They're used for visualization
Okay gotcha.
making gizmos can make your life a lot easier
Yeah, it was all the physics comments that threw me. lol.
I toss them on anything rotation related
to elaborate on the matrix thing a bit
Gizmos.DrawCube doesn't let you specify a rotation. It only takes a center and a size.
Instead, you have to change the space you're drawing the gizmo in.
The default value of Gizmos.matrix is the default Matrix4x4. It's the transform matrix for something that is:
- at the origin
- not rotated
- at the default scale
Gizmos.DrawBox(Vector3.zero, Vector3.one); // draws a cube at the world origin
Gizmos.matrix = transform.localToWorldMatrix;
Gizmos.DrawBox(Vector3.zero, Vector3.one); // draws a cube at your position, with your rotation and scale taken into account
By assigning a different matrix, you change the "point of view" that you draw the gizmo from
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
The idea I was thinking of would only account for your position and scale. It wouldn't let you draw a rotated cube.
Vector3 worldCenter = transform.TransformPoint(Vector3.zero);
Vector3 worldSize = transform.TransformVector(Vector3.one);
Gizmos.DrawBox(worldCenter, worldSize);
It's doing roughly the same thing as changing the matrix, except we can't account for our rotation.
You definitely need to be able to compute these world-space values, though, so that you can run the physics query
Hi, when I put 2 weapon-type items in the equip system, it doesn't let me put a legend-type item, does anyone know why?
👇 👇 👇 👇 👇 👇 👇 👇 👇
https://gdl.space/onekifopom.cpp
perhaps both WeaponList and LegendList are actually referring to the same list
we would need to see the entire script to say
Yep that's the only option I see here
Good thought! But I checked it, they are completely on different lists.
share the entire script please
Also you don't need to check if the elements are there before removing them (lines 39, 43), Remove doesn't do anything if the item wasn't there
Well it returns false, but it won't throw an exception
if anyone here is using gorilla locomotion for their game, when i load in after a few seconds, it just sends me out the map.
This is what happens when I tried to put a legend (after I put 2 weapons in a row)
ok just a minute
that means that your item's category equals "Weapon"
don't make it equal "Weapon"
you appear to be getting the category from a TextMeshProUGUI, which is...a bit odd
is there a collider function that checks continuous collision?
are you looking for a Cast function, like SphereCast?
specifically for trigger2D
OnCollisionStay() I think.
thanks
It's a bug in the script, I've checked it well dozens of times, the legend is from the legends category 100%
Just for good measure, even if you confirmed it, can you tell us the result of Debug.Log(object.ReferenceEquals(LegendList, WeaponsList));
and that would work without OnTriggerEnter?
Yes.
okay, but category.Equals("Weapon") is returning true
you can't really get around that
ok good, the IPointerDown/Up traumatised me last night lol
do you have Collapse enabled on the console?
I'm just trying to find a way to put the legend after I put 2 weapons
Collapse?
well, make sure that category is not "Weapon", then
look at your console
there is a button labeled "Collapse" in the top left
it merges identical log messages
What does this error mean? I'm trying to use a public enum in another class as a case for a switch statement. do I need to make another enum in the class I'm using it from?
I checked it, that's not the problem
I suspect it's hiding the fact that
Debug.Log("EquipItem function called with item category: " + category);
is logging "weapon" three times
your syntax for the case block is wrong
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/selection-statements
There is no way for your code to reach this line:
Debug.LogWarning("Cannot equip more than two weapons at a time. WeaponsList count: " + WeaponsList.Count);
without category.Equals("Weapon") returning true
Actually, not true.
When I tried to do it the other way around **(first the legend then the weapons) **it went to the list of legends.
hmm, I thought gameObject.transform.position would reference the world position of the object the script is on, but it doesn't seem to be the case.
Okay, but what happens when you do it in the way that breaks?
that's what actually matters
it doesn't matter if your code works when you do things in a different order
the problem is that it doesn't work when you do things in this order.
Just put the 2 weapons in front of the legend, that's all I do.
You want to see a video, maybe that will help?
Look at the console after trying to equip the items in that order.
is there a way of doing this like I have here?
Screenshot all of the log entries in the console after doing that.
Before I find where it is 😂
you cannot yield return in a method that returns void
You cannot yield return in a method that returns void. It causes the other error above
yeah thats what its saying
right because you are trying to yield return in a method that returns void
Perhaps you meant to make a coroutine
im wondering if there is a way to achieve the effect id like
IEnumerator?
yes, make it return IEnumerator and start a coroutine with the method.
just like you do with Slow
Oh, for me it's in another language, I understood what you mean
not a coroutine because i dont want to slow for seconds, i didnt change the code in it yet thats my bad
then remove the yield return
@swift crag
is there a way to pass the enemyMovementInstance to it?
You have collapse enabled.
Hi
Anyone that would be willing to help me?
Ask your question.
Ok
Syntax error, question expected
So I have 0 exp in making a video game but I wanna try
heyy chat, me again uwu
how can I destroy the parent of the colliding object along with it here?
Do you have some experience with C#?
Nope
Then check Unity !learn that will provide the required tutorials
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Do that if you want to start with Unity fast. I'd advise learning C# without Unity first though
@short hazel thank you but I can't install Unity
Xsolla: https://xsolla.pro/Blackthornprod
Olobollo on Steam: https://store.steampowered.com/app/1592650/Olobollo/
0:00 - Intro
0:50 - Xsolla Promo
1:24 - Variables
4:17 - GetComponent()
6:08 - Instantiate()
7:52 - Destroy()
9:27 - Loops
13:35 - If/else
16:04 - Input.GetAxisRaw()
18:59 - Vector2.M...
hi, im using unity cloud code and i use a subscription event. How do i disconnect from it ? in code?
^^;
@swift crag Did you find the way?
To be honest I was more looking for a long term collaboration with a Unity programmer
so if i understand it correctly this should result in the enemy being slowed during collision and then slowed again on collision exit for slowLength time https://gdl.space/busobareva.cpp
I thought "localCenter = gameObject.transform.position + center;" would give me a variable that is the world position of the object offset by the "center" public variable, but I'm still having my gizmo appear at the world origin.
There is no line that says "EquipItem function called with item category: " before the error
!collab
We do not accept job or collab posts on discord.
Please use the forums:
• Commercial Job Seeking
• Commercial Job Offering
• Non Commercial Collaboration
I feel like you still have Collapse enabled (I can't tell because you cropped the screenshot)
You can access parent through transform https://docs.unity3d.com/ScriptReference/Transform-parent.html Should look into pooling and reusing objects though. Also note that objects actually destroyed only in the end of the frame.
show your code that draws the gizmo
I don't think it matters but I turned it off
It absolutely matters. We need to see each log message in order.
oh this code is for a currency that the player can collect from the ground ^^;
Collapse will group them together in a way that prevents us from seeing exactly what's happening.
@summer stump thx ^^
Im getting this error right now https://gdl.space/busobareva.cpp
Yes, it's off now. Now show the results of trying to equip the items in that order.
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
notably, there must be a line that says EquipItem function called with item category: visible -- that always gets logged before it tries checks how many items you have equipped
unless you have code somewhere else that also prints the exact warning message you're seeing right now
gameObject.transform.parent.gameObject
found it already, ty tho ^^
Pooling still applies and makes your game a lot more performant. And iirc from version 2021 Unity has a 'native' Pooling solution. I'll see if I can find the vid I saw this morning.
@magic pagoda
https://www.youtube.com/watch?v=U08ScgT3RVM
In this video, you’ll learn more about object pooling, how it can provide performance optimization by reducing the processing power required of the CPU to run repetitive create and destroy calls, and how to use it in your Unity projects.
⭐ Learn more about programming design patterns in this e-book: https://on.unity.com/3O6tR8J
⭐ Check out Unit...
This does not make any sense, assuming that line 44 of EquipSystem is the only way for that warning to be logged. Your code has to go through the first few lines of the EquipItem method before it can even log anything.
If you click on that warning, is it actually coming from the EquipSystem class?
Cannot equip more than two weapons at a time. WeaponsList count: 2
UnityEngine.Debug:LogWarning (object)
ItemEquip:EquipItem () (at Assets/Scripts/Systems/Equip/ItemEquip.cs:46)
ItemEquip:ToggleEquip () (at Assets/Scripts/Systems/Equip/ItemEquip.cs:34)
UnityEngine.EventSystems.EventSystem:Update () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:514)
im getting this when i exit playmode, would it impact the game at all if scenes were to change etc?
this is the wrong script
you've showed us EquipSystem
the error is coming from ItemEquip
Ahhhhhhhhhhhhhhhhhh
double click on your log messages to find out where they're actually coming from
Are you kidding me? All this time it was from another script?
😂
ItemEquip:EquipItem () (at Assets/Scripts/Systems/Equip/ItemEquip.cs:46)
Class | Method | Path to file | Line of code
@swift crag It's been two weeks since the problem started. Thank you!
what should I be using to get the Vector3 of the world position of the object my script is on?
https://hastebin.com/share/ividanarid.csharp weird, I did that and it's still drawing my gizmo at origin.
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Perhaps you are moving the object that BoxRegion is on after Start runs
I knew there was a hidden question underneath that lol
😭
also, I don't know what boxTransform is
something I was gonna use for making a fully transformable gizmo, but decided better of it.
deprecated variable for now >.>
something must be moving BoxRegion after its Start method runs, then
Perhaps someone else repositions them in its own Start method.
Instead of calculating the local center once, you should really just make a property that gives you the correct world-space center
public Vector3 WorldCenter => transform.TransformPoint(center);
"world center" is the appropriate name here: it's a position in world space
center is being interpretated as a local-space position in that line of code
would this work to not make the OnTriggerExit happen if an object was destroyed?
huh, it seems it was in fact the object not being in the right place at Start
other should never actually be null
your problem would be the coroutine doing something after the target is destroyed
im getting this before the coroutine though
what is line 28?
on the enemyMovementInstance.moveSpeed = line
what if enemyMovementInstance is null?
maybe you hit a trigger collider that doesn't have an EnemyMovement on it
your script doesn't check if it actually got an EnemyMovement in the first place
Consider using TryGetComponent here.
if (other.TryGetComponent(out EnemyMovement enemyMovement)) {
// enemyMovement will be non-null in here
}
// enemyMovement might be null out here
Actually, a more concise way is to just bail out if it fails
if (!other.TryGetComponent(out EnemyMovement enemyMovement))
return;
// enemyMovement is definitely not null here
This creates a new variable as it calls TryGetComponent. It's passed with the out keyword, which lets the method assign something to your variable.
The method returns true if it succeeds.
So, if it returns false, we just return immediately
once we get past that check, enemyMovement is definitely valid.
so like this?
i assumed the issue was objects being destroyed and OnTriggerExit being called but it could be that the triggers were overlapping and triggering eachother now that i think about it
would explain the error being sent twice as well
Actually, that is a good thought. I don't remember what happens when an object dies while overlapping.
either way now it will only do this if it gets the component
That looks reasonable.
You're searching the component on yourself, not on other, make sure that's correct.
oh, whoops
would that be other.TryGetComponent
Correct.
OnTriggerExit does not get called when an object is destroyed inside the trigger area iirc
https://docs.unity3d.com/ScriptReference/Physics2D-callbacksOnDisable.html
Looks like you can control whether callbacks occur as a 2D collider is being diasbled
(which is part of destruction)
It defaults to...i don't know
Only if you expect the component to be on the object you triggered with, but seeing the context that's a yes
Oh, that is good to know. Nice
so if i understand this correctly, by setting callbacksOnDisable to false, it will not trigger OnTriggerExit when destroyed?
Yes, but I wouldn't mess with that (also, you can toggle it in the Project Settings menu, so there's no need to use code)
I guess I'd change if it was actually causing problems for me
note that you often will want to know about when an object is destroying while you're overlapping it
e.g. if you're keeping a list of things you're currently touching
i thought it just broke my sound in the game
but my headset got unplugged
lol
what's the point of using [SerializeField] private Transform instead of public Transform?
It prevents other scripts from changing or accessing the variable
[SerializeField] only allows the inspector to see and change it
private fields can't be seen by other classes, which reduces clutter and reduces the number of ways class A can interact with class B
i'm actually fixing a bunch of public fields that shouldn't be public right now
Public allows other scripts from changing the values, Serialize keeps it private to the current class, but exposes it in the Inspector.
Access modifiers matter more when you're writing code that other people will use.
But I consider "me from six months ago" to be another person entirely 😛
Im trying to figure out how to register a highscore? I have two scripts that already link up so that I can display my current score, but how do I register and keep a high score? Im guessing player prefs but I dont really know how to use those. The two pictures are my logic script, which is where i think im supposed to store the highscore and the collosion script for registering points.
in that case, people might start relying on these public fields
I was about to say exactly that haha
now you can't change the field without breaking everything
gotcha, also I got the animations working @short hazel 😄
still havent gotten around blend trees tho, need to read up on them I just ended up with a bunch of if/else scripts
PlayerPrefs is very easy to use tbh. But I know a lot of people think that they're a bad idea. But to get a high score, it's relatively simple really. Have a High Score variable, if the current high score is null then = it to 0, then on death or game complete etc. simple compare current score and high score, if current score > high score, current score = high score, else nothing, and then throw the new high score to wherever you're saving it. When you start the game again just read in the high score and assign it to the high score variable.
private void OnEnable()
{
InputController.Instance.InputMaster.Player.SpawnCheckpoint.performed += TrySpawnCheckpoint;
}
Any idea why the subscription does not call TrySpawnCheckpoint when F is pressed?
Any chance you activated your InputController
OnEnable is called, yes
I presume that InputMaster was produced with the "Generate C# Class" checkbox.
Yes
If so, you must enable the relevant actions or action maps.
Actions aren't enabled by default.
see the example code here
(oops, InputMaster, not InputController)
This is from another project:
/// <summary>
/// If the input controller script is enabled, the master is enabled as well.
/// </summary>
private void OnEnable()
{
Master.Enable();
}
/// <summary>
/// If the input controller script is disabled, the master is disabled as well.
/// </summary>
private void OnDisable()
{
Master.Disable();
}
Is there a reason why they are disabled by default? Doesn't that just lead to lunacy like that?
I guess what I'm asking is, shouldn't the reverse be the default setting
because
maybe if you only have a single action map or something
(which is roughly how the PlayerInput component behaves -- it enables an action map for you)
but if you have a Walking action map and a Flying action map and a Driving action map, it doesn't make sense to have all of their actions firing all the time
🤷♂️ Maybe. But thanks for your help :D
is there a better way of doing this?
You can just do transform instead of gameObject.transform and .parent is already a transform so you don't need to get the transform from it
Also you could just use GetComponentInParent
would that work if its 2 objects deep?
as in its a child of a child of the object i want the script from
Pretty sure, 
digging around the hierarchy like this will work, but it's also very brittle
if you change the layout at all, you suddenly can't find what you're looking for
you should try to just directly reference things you need
also transform.root.GetComponentInChildren
why is that error appearing?
hi, how i can manually unsubscribe?
If you use an anonymous function, you'll have to actually save that exact delegate and unsubscribe with it later.
An identical-looking anonymous function won't work, since they're two different instances.
i unsubscribe on a scene to resubscribe in next scene
Yes. If you do this:
callbacks.Kicked += () => ...
then it's impossible to unsubscribe, since you don't have a reference to that exact delegate anymore
callbacks.Kicked -= () => ... would do nothing, because that's a completely separate object
I would create methods to replace those anonymous functions, and subscribe/unsubscribe those.
oh, ok ty
how would i go on and use the "highlight" variable in another if statement?
Declare it outside of the if statement
Remove the var in front and just do highlight =
Make it either a variable declared just inside the first getbutton or a class variable
Hi, I have a question regarding animation frame when dialogue is activated.
This is my code: https://paste.ofcode.org/363FzMs62P4y8JDvSLW45Cg
I implemented animator enabled to be false to stop the animation but now when my character is sprinting or walking and I start dialogue, it pauses at the last animation frame in either walk or sprint mode.
Is there another way to implement the code so that it defaults to my idle animation and doesn't allow the player to do any movement keys once we are in dialogue mode?
I think you should refactor your code then if you need to disable your animator to force idle position.
What does refactor your code means?
Or should I add a SerializeField for indialogue, and then let animator detect it is in dialogue and transition animation to a idle pose?
means consider changing up your logic, because if your character isn't doing any actions, they should default into an idle state, no?
but how would I script it in here
Yes, but I don't want to allow the player to be able to press the move button becuse it looks funny in dialogue that the player is running nonstop
since they can still walk but in a static position
I'd first look into disabling input for that then
ok, so in this case I have to specific the move input to be disable right? else they can't press anything for dialogue to continue. I'll look that up
if movement is tied to dialogue keys, then you could consider using a flag to determine if you should move the player
probably the most simplest way if you don't want to go into creating different input maps
why isn't the rotation part working at all? no errors or nun
Getbutton and getbuttondown? Why not just getbuttondown? Print out the angle and see what it gives you.
cuz i need to clone the object once and then rotate it every frame when the player holds
Have you debugged what the angle is specifically? Also what's the use case for this, it does look strange
it always debugs 0
what do i do?
you look at the error and debug
it says it cant convert float to a vector 3
I would assume acceleration needed would be a float? Did you declare it as as Vector3?
Either way, magnitude is a float
Try to print(highlight == null) if true that you are not creating an object
Depends on what you're doing with it
Magnitude is a float though
in this case im going to add it to targeted direction and apply that as a force to an object
Like mentioned above it depends. Right now you have a single number and saying ok now map it to x y and z? How you gonna do that with one number?
Then maybe just add direction directly instead of making this accelerationNeeded variable at all
You can add vectors together. You can't add a float to a vector (but you can MULTIPLY it)
okay
im just a bit confused on what to do for my grab system
A guy was telling me to add magnitude to a direction
Finding out why that happens would be a good start, maybe say what you're trying to do in terms if your game though so people can suggest a better way
Multiplying a vector by a float will change the magnitude while keeping the direction the same
so how do i know what to multiply it by
The first step would be to understand what you're doing
Both from a gameplay and math perspective
i dont know im just confused
my goal is just to get a object to a target point physics based
//Make a list of the empty objects in the GridLayout panel
List<GameObject> _gridEmpty = new();
foreach (GameObject child in GridLayout)
{
_gridEmpty.Add(child);
}
Why is this throwing a InvalidCastException: Specified cast is not valid. error?
presuming GidLayout is a transform then it's children are also Transforms
It's a GameObject with a RectTransform, and the child objects I want to destroy in it have normal Transforms.
ok, show the declaration for GridLayout
Hold on, I think I might have fixed it, let me check.
it is creating the object it just doesn't rotate towards the mouse
Yeah, I managed to figure out what was wrong, thank you for the help.
why does the angle always debug to 0
does this look okay for animating the character based on their movement speed?
how do i post code?
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
First of all, why would you do a foreach but still access the array by index, second of all, there's this thing called the Animator which has a speed property
can you access it with animSprites[sprite]?
The sprite is already the Sprite you want.
cool
oh yeah youre right
if (Holding)
{
TargetDirection = TargetPoint.position - Grabbed.position;
Grabbed.transform.GetComponent<Rigidbody>().AddForce(TargetDirection * 2f, ForceMode.Acceleration);
}
how do i make it so it gets exactly to the target point with physics
why does the angle always debug to 0
make new var for Mouse in the world
var mouseWorldPos = Camera.main.ScreenToWorldPoint(mousePos)
can somebody help me positioning a UI text in a sprites position
is this a code question, cause this is a coding channel
Hey, guys! Why I see that instead of the text I want to activate?
still nothing
Whenever my player enters the other trigger I want to activate the text inside the text component
did you Import the TMP essentials
Yes of course!
can you screenshot the TMP component
is the script running ?
yeah, i mean doing it via script
so is the sprite a world object ?
use WorldToScreen
probably just change the text order in layer to a bigger number like 100
i tried, and the text pops but not in the position of the sprite
did you replace the var in the Atan2 btw
yh
yh
@wary dagger you tried this?
show me how you wrote it
tf
show the console prints
Here
I have a feeling your camera is Prospective isnt it..
yup prospective cam
do i change that to orthographic?
orthographic = no depth
do you not want depth in your game
are you doing 2D or 3D
yh but how else can i fix that
3d
just project onto a plane and get that direction then
with screentoray
is there a function that can find a new Vector3 by taking an old Vector3 and a quaternion?
Yo @rich adder you probably dont remember me but you helped me out before thanks
you tried a different font ?
what?
Anyone know if you can run scripts from instantiated prefabs on start?
why wouldnt you
also prefabs dont run scripts
gameobjects do
prefabs are just "templates" to a gameobject
they arent a thing during runtime
like this?
Can't understand something, maybe someone can help me out with it, i'd be glad. I am generating a grid via this code
private void GenerateGrid()
{
gridCells = new RoomGridCell[gridSizeX, gridSizeY];
for (int x = 0; x < gridSizeX; x++)
{
for (int y = 0; y < gridSizeY; y++)
{
gridCells[x, y] = new RoomGridCell();
gridCells[x, y].roomIndex = new Vector2Int(x, y);
if (y + 1 < gridSizeY) gridCells[x, y].top = gridCells[x, y + 1];
if (x + 1 < gridSizeX) gridCells[x, y].right = gridCells[x + 1, y];
if (y - 1 >= 0) gridCells[x, y].bottom = gridCells[x, y - 1];
if (x - 1 >= 0) gridCells[x, y].left = gridCells[x - 1, y];
}
}
}
then I have a startingRoom at index [7,7] in the grid. The gridSizeX and gridSizeY is both 15. I don't understand why startingRoom.top is null :/
RoomGridCell startingRoom = gridCells[gridSizeX / 2, gridSizeY / 2];
Debug.Log(startingRoom.roomIndex.y);
Debug.Log(startingRoom.roomIndex.y+1);
Debug.Log(gridSizeY);
Debug.Log(startingRoom.top);
Debug.Log(startingRoom.right);
Debug.Log(startingRoom.bottom);
Debug.Log(startingRoom.left);
@rich adder can you see the video?
8 is less than 15, so why it didn't assign .top here?
well no this only works if you hit something
is your game top view ?
I want a box to appear in a random point out of 2 positions set on the prefab when the prefab is instantiated, any idea how I would do this.
check out this vid talks about
https://docs.unity3d.com/ScriptReference/Plane.html
https://docs.unity3d.com/ScriptReference/Plane.Raycast.html
https://youtu.be/TyAlFihknfQ
There weren't any tutorials on using the Plane struct in Unity, so here it is.
Introduction to Planes: 0:00
Creating a Plane: 01:43
Finding the Closest Point on a Plane: 4:06
Finding a Point's Side on a Plane: 6:06
Finding Ray Intersections on a Plane: 8:32
Unity Plane Documentation: https://docs.unity3d.com/ScriptReference/Plane.html
Fish AR ...
Let's say there's a sphere whose center is 0,0,0, and I've been given a point on the surface of the sphere in the form of a Vector3, and a rotational translation applied to the sphere in the form of a quaternion. Is there an existing Method that I can call to find what the new Vector3 location of the point would be?
mkv doesnt work on discord. you need mp4
hello how do i make a window that changes graphics settings before opening game
ah yeah Most likely, i just forgot which, need to remember it
maybe someone else knows
I want a box to be instantiated at a random point out of 2 positions set on a prefab when the prefab is instantiated, anyone have an idea how I code this. I dont now how I would reference the coordiante positions of the 2 points that are in the prefab
when you instantiate something you get an Object in return
MyScript myObject = Instantiate(etc...
var someVariabel = myObject.MyPublicVariable```
same as
```cs
GameObject myObject = Instantiate(etc...
var someVariabel = myObject.GetComponent<MyScript>().MyPublicVariable```
oh wait i see one problem let me fix it and see
https://hatebin.com/aanqyafqqt same problem
private void Start()
{
rectTransform = GetComponent<RectTransform>();
}
public void Pop(Vector2 screenPos)
{
rectTransform.anchoredPosition = screenPos;
}
isnt this script on the pieces?
yeah did that, check the second link but the problem is same
no i know but its wrong
pieces scripts
yes but you want the textPop
yes, when the piece is clicked
yes but you're doing GetComponent
rectTransform = GetComponent<RectTransform>();
this is wrong if the script is on the piece
its not on the piece
you need the rectTransform of the text
this is on a text
so why does it have OnMouseDown ?
i just pasted two codes from two different scripts
when you send a script dont omit the class name etc.
ohh wait
hmm curious about something, can you show one of those sprite pices you spawn
like their pivot n stuff
maybe its cuz of canvas settings?
cause i tried scaling it with screen size so it fits on every screen but it actually has no point in that case
yeah maybe you need to account canvas scale
iirc it just worked for me last time
have you tried regular .position =
instead of anchored pos
just curious if it prob is canvas scaling messing with it
yes yes
anchoredPosition is relative to your parent.
ahh true
and what is localPosition then?
relative to parent but world coords, the anchoredPos is the position from anchor
localPosition doesn't care about the anchors (which determine whether or not your RectTransform stretches)
I'm a bit fuzzy on the details. I need to go play around with that a bit.
How can I make my 8 directional character controller 4 directional
modify it
is there a way to Instantiate the gameobject youre firing the script from?