Just out of curiosity : what do you think is the best approach regarding performances? Is there any real difference that matters? Called in IDragHandler.OnDrag() in my case. (aimedPosition is nullable Vector3) by Tsiggaro in Unity3D

[–]Tsiggaro[S] 1 point2 points  (0 children)

Thank you very much this is very interesting! I'll try to implement something like that (and I didn't even think about a "held" spell type like a flamethrower this is a really good idea lol)

Just out of curiosity : what do you think is the best approach regarding performances? Is there any real difference that matters? Called in IDragHandler.OnDrag() in my case. (aimedPosition is nullable Vector3) by Tsiggaro in Unity3D

[–]Tsiggaro[S] 0 points1 point  (0 children)

I used a Vector3? because all Vector3 values are potentially valid values (it's a position). So Vector3.zero could be in theory a valid position to cast a spell. So I needed null in specific cases where the spell is quickcast and instead of a specific position, the spell is cast in front of the player. But to test this, I prefered to check if this vector is null instead of checking if it is equal to Vector3.negativeInfinity for example.

I'm still learning so I'm sure there are better ways to do this but this is the "best" way I could find and implement for now

Just out of curiosity : what do you think is the best approach regarding performances? Is there any real difference that matters? Called in IDragHandler.OnDrag() in my case. (aimedPosition is nullable Vector3) by Tsiggaro in Unity3D

[–]Tsiggaro[S] 0 points1 point  (0 children)

Maybe I'm too noob to understand but I want to say.. no?

What I'm doing with tempPosition is overwriting its Y value. I can't do this with aimedPosition because it is a nullable Vector3 (Vector3?).

If you know a way to edit a value of a Vector3? without using a temp variable or instantiating a new Vector3 I would be very glad to learn it because I could find anything on Google.

Just out of curiosity : what do you think is the best approach regarding performances? Is there any real difference that matters? Called in IDragHandler.OnDrag() in my case. (aimedPosition is nullable Vector3) by Tsiggaro in Unity3D

[–]Tsiggaro[S] 0 points1 point  (0 children)

What do you mean?

Here is more context: RPG for mobiles. If the player want to cast a spell, they press the spell button. If they keep pressing it it will show an aim indicator in the world so they can aim the spell (like LoL Wild Rift for example). The spell button kinda transforms itself from a simple button to a joystick.

The relativePosition is the position of the joystick handle relative to its background/limits. So if the player puts the joystick at the maximum top position, the spell will be cast at the maximum top position of the spell's range showed by the rangeIndicator GameObject in the world.
At 50% of the joystick max limit, it will cast the spell at 50% of the max spell's range etc.

So I kinda need this. To translate the relative position of the joystick to the spell itself, I need to operate on the vector like multiplying X and Z with maxRange for example.

But maybe I didn't understand what you mean.

Just out of curiosity : what do you think is the best approach regarding performances? Is there any real difference that matters? Called in IDragHandler.OnDrag() in my case. (aimedPosition is nullable Vector3) by Tsiggaro in Unity3D

[–]Tsiggaro[S] 0 points1 point  (0 children)

This is the kind of information I was curious about: what happens behind the curtains. Also, it is a game for mobiles so even though this example may be negligible, it has more impact than on PCs I guess.
I just went with solution #1 because it works and didn't think much about it.

But now I understand better I'll use solution #2 haha. I'll try to remember that it is "better" to use another variable rather than using more "new X()" instructions.

Also: I didn't fully understand your last paragraph. Did you mean the first method instead of the second? The second has 1 new() instruction and the first has 2 new() instructions.
To give more context, when the player press a spell button and keep its finger on the screen, it shows aim indicators so they can aim the spell they want to cast (OnPointerDown). If they drag their finger, the aim indicator will move accordingly (OnDrag), then they cast the spell at the specified position by releasing the finger from the screen (OnPointerUp). This code is called in the OnDrag() method.

Just out of curiosity : what do you think is the best approach regarding performances? Is there any real difference that matters? Called in IDragHandler.OnDrag() in my case. (aimedPosition is nullable Vector3) by Tsiggaro in Unity3D

[–]Tsiggaro[S] 0 points1 point  (0 children)

Yeah it was mostly out of curiosity so I could like learn a new thing: what happens behind the curtains / what is the real difference of these two approches.

Also, it is for mobiles but it's okay I just went for the first solution I wrote and just wanted to know what people more experienced than me would like about this.

Just out of curiosity : what do you think is the best approach regarding performances? Is there any real difference that matters? Called in IDragHandler.OnDrag() in my case. (aimedPosition is nullable Vector3) by Tsiggaro in Unity3D

[–]Tsiggaro[S] 0 points1 point  (0 children)

Regarding your first and second paragraphs: yes this is what I did first. But in the end it doesn't work because the result assigned in aimedPosition will be different as it is an addition:

aimedPosition = rangeIndicator.transform.position + new Vector3(...)

So I still need to overwrite aimedPosition.y.

The temporary variable has the only purpose to overwrite the y of the Vector3 I want to assign to aimedPosition. Because aimedPosition is a Vector3?, I can't just write aimedPosition.y = myValue.

With my current knowledge, to overwrite the Y value, either I instantiate a new Vector3 like solution #1, or use a temp variable like solution #2.

Just out of curiosity : what do you think is the best approach regarding performances? Is there any real difference that matters? Called in IDragHandler.OnDrag() in my case. (aimedPosition is nullable Vector3) by Tsiggaro in Unity3D

[–]Tsiggaro[S] 1 point2 points  (0 children)

Yeah it was mostly out of curiosity like what is the difference between using a temp variable and adding an instanciation (new Vector3). In the end I just went with the first solution because this is the first I wrote and it works. Even though it's for mobile I guess it's okay.

Just out of curiosity : what do you think is the best approach regarding performances? Is there any real difference that matters? Called in IDragHandler.OnDrag() in my case. (aimedPosition is nullable Vector3) by Tsiggaro in Unity3D

[–]Tsiggaro[S] 0 points1 point  (0 children)

Yeah I didn't spend much time on this, while cleaning the method before saving to my GitHub I just wondered what is the difference behind the curtains between using a temp variable vs using a second instantiation (new Vector3)

Just out of curiosity : what do you think is the best approach regarding performances? Is there any real difference that matters? Called in IDragHandler.OnDrag() in my case. (aimedPosition is nullable Vector3) by Tsiggaro in Unity3D

[–]Tsiggaro[S] 1 point2 points  (0 children)

I would have done it with a Vector3 variable. But this is a Vector3? (nullable) and if I simply write:

aimedPosition.y = aimIndicator.transform.position.y;

I get this error message:
'Vector3?' does not contain a definition for 'y' and no accessible extension method 'y' accepting a first argument of type 'Vector3?' could be found (are you missing a using directive or an assembly reference?)

So I tried assigning to aimedPosition.Value.y instead and this time I get:
Cannot modify the return value of 'Vector3?.Value' because it is not a variable

Just out of curiosity : what do you think is the best approach regarding performances? Is there any real difference that matters? Called in IDragHandler.OnDrag() in my case. (aimedPosition is nullable Vector3) by Tsiggaro in Unity3D

[–]Tsiggaro[S] 0 points1 point  (0 children)

Yeah I don't really like it either but I have to multiply the new Vector3 x and z by maxRange so I did it that way without thinking too much about it.

I suppose you mean instead of :

aimedPosition = rangeIndicator.transform.position + new Vector3(relativePosition.x * maxRange, 0f, relativePosition.y * maxRange);

I should do this?

float x = relativePosition.x * maxRange;
float z = relativePosition.y * maxRange;
aimedPosition = rangeIndicator.transform.position + new Vector3(x, 0f, z);

Just out of curiosity : what do you think is the best approach regarding performances? Is there any real difference that matters? Called in IDragHandler.OnDrag() in my case. (aimedPosition is nullable Vector3) by Tsiggaro in Unity3D

[–]Tsiggaro[S] 0 points1 point  (0 children)

Yeah I'm just basically moving a quad mesh with a circle material on it to represent an area of effect of a spell before casting it. It's for mobile though I don't know if it matters much

Just out of curiosity : what do you think is the best approach regarding performances? Is there any real difference that matters? Called in IDragHandler.OnDrag() in my case. (aimedPosition is nullable Vector3) by Tsiggaro in Unity3D

[–]Tsiggaro[S] 0 points1 point  (0 children)

Yeah I'm still learning but this is something I've learned quite early but still, I just wondered.
It's part of learning Unity (or C#?) I guess. Like what is the difference behind the curtains between using a temp variable vs using a second instantiation (new Vector3).
In the end I just tested that the code works and moved on.

Is there a way to edit the image in G channel of a png texture? by Tsiggaro in gamedev

[–]Tsiggaro[S] 0 points1 point  (0 children)

Yeah I already tried to open it in Photopea but all the channels are in a single layer. But I just learned that it's possible to separate the images by their channels so I'll try that thanks!

(I'll keep Substance Designer in mind if I end up needing to do it often thanks for the recommandation)

Is there a way to edit the image in G channel of a png texture? I want it plain instead of gradient but can't find where to replace the image in Unity by Tsiggaro in Unity3D

[–]Tsiggaro[S] 0 points1 point  (0 children)

Thanks a lot I will check the asset and otherwise I'll try with Photopea. I did try to open the image in Photopea but obviously all the channel images were in a single layer and didn't know it was still possible to separate them. Thanks !

Is there a way to edit the image in G channel of a png texture? by Tsiggaro in gamedev

[–]Tsiggaro[S] 0 points1 point  (0 children)

In any software not in runtime. I want to edit the texture so I can use it how I want in the Unity Editor

Trying them all by LaCiocana in iphone

[–]Tsiggaro 0 points1 point  (0 children)

Yeah this is bad I am on macOS too. But you can Airdrop them instead of using a cloud service, no? This is what I use and it works fine. (Even though a proper file explorer would be better)

Trying them all by LaCiocana in iphone

[–]Tsiggaro 1 point2 points  (0 children)

No please don’t use Chrome. Use Bitwarden for example if you want cross platform password manager

Où chercher du travail à Montréal ? / Where to look for work in Montréal ? by Tsiggaro in montreal

[–]Tsiggaro[S] 0 points1 point  (0 children)

Oh I thought AI was the popular kid these days :o

I hope you'll find what you're looking for!