Ok, I have just started (yesterday) to code around with c# leaving javascript alone because latest threads in the forum convinced that i should make that move… so I am not really proficient (yet) in c# anyway, striping out everything else, i have a code saying this:
public class PlayerController : MonoBehaviour
{
private Vector3 pointerDirection;
private Vector3 ProvideInfoSecondPass(Vector3 firstPassInfo)
{
pointerDirection = Vector3(firstPassInfo.z,0,firstPassInfo.x);
return pointerDirection;
}
[BLABLABLA];
}
This gives me an error, exactly
Assets/Scripts/PlayerController.cs(43,25): error CS0119: Expression denotes a `type', where a `variable', `value' or `method group' was expected
If i am right, it is saying that i am trying to assign to Vector3 2 types instead of values… but Vector3.x and Vector3.z return floats, not types (or am i wrong?)
Thanks For Help
Philip
Hey Philip,
Try replacing this line:
pointerDirection = Vector3(firstPassInfo.z,0,firstPassInfo.x);
with this:
pointerDirection = new Vector3(firstPassInfo.z,0,firstPassInfo.x);
Wooho! Thanks for the quick answer…
It’s working now (finally), but can you tell me what oes this “new” actually does?
I usually prefear to understand what i type.
Thanks,
Philip
Thanks, It’s working now…
By the way… can you tell me what you think wasn’t working, and what does actually “new” does? I usually want to know what i write down.
Thanks a lot
Philip
Edit:
finalDirection is vector3
finalspeed is float
movementComplete = finalDirection * finalSpeed;
… same problem… will try to fix this in the same way… but looking forward to an explanation
EDIT2: fixed with new Vector3(finalDirection.x, finalDirection.y, finalDirection.z) * finalSpeed;
New instantiates a new object of said class.
In javascript you do not require the new as it does a lot of the stuff on its own behind the scene.
As for your second problem: I don’t see a reason why your solution should be required if the original ones worked.
Sure you are having a Vector3 and a Float there and that you are assigning them to a Vector3 again?