#Operators (Vector3,Float,Double)

1 messages · Page 1 of 1 (latest)

novel path
#

Hi All, i just joined the server. I was hoping some expertise might help in my confusion.

#

I'm not sure my entire last message sent but in general hello 🙂 im getting an issue when following a tutorial where the** *error CS0019: Operator '' cannot be applied to operands of type 'Vector3' and 'double' i have read a few forums where people discuss that it is not possible to do this but I cannot seem to find a workaround, any advice or input would be hugely appreciated.

sage galleon
novel path
#

Hey Desaw 🙂 "Vector3 movement = this.transform.forward * verticleAxis + this.transform.right + horizontalAxis;" - this is thhe guy

sage galleon
novel path
#

yes it is, referenced 2 lines before

sage galleon
#
Vector3 movement = this.transform.forward * verticleAxis + this.transform.right * horizontalAxis;
#

Did you want to write this?

#

You maybe accidentally added up transform.right with horizontalAxis expect multipling it

novel path
#

let me double check that!

sage galleon
#

I dont know if this is what you wanted to do

novel path
#

im trying to make a move function

#

i have two floats vertical and horizontal

#

I use Input.GetAxis to retrieve these

#

then i want to create a vector called movement but in this line it says i cannot use operators such as *

sage galleon
#

what should the movement vector say

#

like where its going?

novel path
#

it goes to an animation controller i setup , both going to the vertical and horizontal axi of that component

#

i hope that makes sense

sage galleon
#
Vector3 movement = this.transform.forward * Input.GetAxis("Horizontal") + this.transform.right * Input.GetAxis("Vertical");
#

works perfectly for me

#

no errors

novel path
#

yeah thats the one!

#

i tried out your code, and it got rid of my error with some small exceptions

#

must not have liked me declaring it outside of the vector

sage galleon
#

so does everything work now?

novel path
#

not everything but that definitel gave me some progress, thanks 🙂

#

got some weird glitches to fix on my character