New answers tagged

0 votes

The WebGL version of my game does not load the next scene when using an async action

According to this Unity forum discussion, Task.Delay uses a thread, which is not available when building for WebGL. Try converting your code to use a coroutine with ...
DMGregory's user avatar
  • 134k
0 votes

how can I distance camera according to player speed?

Use SmoothDamp, very similar to what you are currently doing with the Y axis. ...
Kevin's user avatar
  • 5,734
0 votes

Draw Primitives using SharpDX.Direct3D9 with C# .NET Framework

Well, you can now draw primitives, all with lines, and using mathematics. (I tried to place the code here, but it is bugged, but it shows me everything wrong.) Here I show how I did it: Source I guess ...
S4L salsoft's user avatar
1 vote
Accepted

Why doesn't Coroutine work the way I want with if blocks?

Your array TotemKoruyanlar has only 2 elements, but your loop tries to access 7. This will cause an array index out of range exception and stop the coroutine from ...
Paul's user avatar
  • 131
0 votes
Accepted

How to make camera follow player on Y+ axis only

I'd do this in LateUpdate to ensure the camera moves after the player, as liggiorgio suggests. This avoids judder where we smoothly follow the player but then the ...
DMGregory's user avatar
  • 134k
0 votes

How to make camera follow player on Y+ axis only

If the camera and the player were independent GameObjects, a viable strategy would be: Update the player's position first. Update the camera's position last. The ...
liggiorgio's user avatar
  • 4,716
0 votes

How to make camera follow player on Y+ axis only

2d? You could do: ...
CheckerT's user avatar
2 votes

scale and rotate a cube automatic the cube is never scaling and rotating to the end. how to fix?

I'm not well-versed in Unity C# scripting, but I'm guessing your Scale() function starts a process that changes your scale over time. Thus, if you were to call this function each frame, it would start ...
Gyoo's user avatar
  • 176
1 vote
Accepted

Turn a 2D array into a 3D map

I finally got some success! I got the clue from this reddit post: https://www.reddit.com/r/godot/comments/lc6cxz/merge_a_grid_of_polygons_into_one_polygon/ This might not be the final form, and it can ...
AndyD273's user avatar
  • 163
0 votes

How do I move both the child & parent game objects at the same time?

Fixed! Turns out my y constraint wasn't frozen on the rigidbody.
Saltii's user avatar
  • 1
1 vote

Adding a function call to a prefabbed button in Unity

If you instantiate the button you can get a reference to it, like GameObject _Button = Instantiate(_ButtonPrefab) and then you can call ...
CheckerT's user avatar
0 votes

Why are my angle calculations not working properly?

To convert degrees to radians, you need to multiply the angle in degrees by Mathf.PI / 180.0f. HAZ = (float)0.8 * Mathf.Tan((ha * Mathf.PI) / 180.0f);
Nick NaSvlishvili's user avatar
1 vote

How to implement C# methods that automatically get called in the game loop, like Unity's Update() etc.?

You can create event handlers, that components can subscribe to; and that are called when that event occurs. This pattern is most suitable when you have multiple "subscribers" that "...
Gerry Schmitz's user avatar
0 votes

Unity Game Architecture

Ultimately, I find that giving classes meaningful names, and using "as many namespaces" as necessary to make sense of it all, is what keeps things sane. The harder a class is to name, the &...
Gerry Schmitz's user avatar
-1 votes

Kinematic "dive bomb" motion toward a moving target

Based on the image, the rubble is moving in the x direction, and the asteroid in x,y. Using 3 DoubleAnimations (StoryBoard) and a common target point (CompositeTransform.TranslateX and Y for asteroid; ...
Gerry Schmitz's user avatar
-1 votes

How can I securely store Gmail SMTP credentials in a Unity project to comply with security guidelines?

Consider "Isolated Storage". Using isolated storage enables partially trusted applications to store data in a manner that is controlled by the computer's security policy. https://learn....
Gerry Schmitz's user avatar
0 votes

Different Spacing of all Children Grid Layout Group

Create the prefab with a few possible positions of the triangle. Then each cell will contain this prefab. Then set the triangle to the random (or defined) space inside the prefab. For example each ...
Bogdan's user avatar
  • 133
0 votes

Different Spacing of all Children Grid Layout Group

The "simplest" way is to populate a Canvas; so you don't have to worry about "rows and columns". Starting from the "origin" (0,0), you "chunk" your way from top ...
Gerry Schmitz's user avatar
1 vote

Type or namespace name 'Collider' could not be found

You need to add using UnityEngine; to the very beginning of the script because unity does not know what a collider is. As the error suggests: are you missing a ...
CheckerT's user avatar
1 vote

Type or namespace name 'Collider' could not be found

This is the compiler saying "I don't know what this Collider name is referring to". Collider is a class in the ...
DMGregory's user avatar
  • 134k
3 votes

How can I securely store Gmail SMTP credentials in a Unity project to comply with security guidelines?

Since your goal is to send feedback to yourself, there are others ways instead of storing or even giving the credentials to the asset. As Almo pointed out, giving your credentials to a random asset is ...
Zibelas's user avatar
  • 4,291
24 votes
Accepted

Avoiding string literals to reduce memory allocations

A string literal in C# will be compiled to string literals in IL. Then the IL is compiled to machine (or to C++ and then to machine code if you are using IL2CPP). On machine code the strings constants ...
Theraot's user avatar
  • 26.7k
5 votes

Avoiding string literals to reduce memory allocations

There is a trick with strings called "interning" Which stores the string in a global pool and lets you get the same string object for the same string contents. C# is defined to automatically ...
ratchet freak's user avatar
0 votes

Kinematic "dive bomb" motion toward a moving target

This is how I would do it: The first thing you would need to do is calculate a vector from the position of the asteroid to the end position. ...
Pow's user avatar
  • 383

Top 50 recent answers are included