- Home /
Can someone help me slow this object down?
Hi there, So I mastered the code of making an object(my helicopter) fly across the screen, but it's at vector speed 1 which is excruciatingly fast. I add a 0.3 decimal to slow down the object, but it says that the '*' sign is invalid and can not be doubled or something like that. Could someone please help with this? Thanks! Gabriel
Please insert the code and the exact error message you get to help find the error.
Ok, here is the line of code I'm working with: transform.Translate(Vector3.left * 1); And here is the error message: Assets/Scripts/Enemy$$anonymous$$ovement.cs(13,45): error CS0019: Operator *' cannot be applied to operands of type UnityEngine.Vector3' and `double'
Thanks for your help!
Answer by fffMalzbier · Nov 27, 2015 at 10:31 AM
You can not multiply a Vector3 with a value of type double. You have to declare the value as a float if you use a comma value.
Vector3 test;
test = Vector3.up * 1; //integer -> Does work.
test = Vector3.up * 0.3;//double -> Does not work. will produce CS0019
test = Vector3.up * 0.3f; //float -> Does work.
Thank you so much!! That worked perfect. Just one last thing. Do you know how I can randomize the number of enemies that come from off-screen? I want to be able to make a certain amount fly out just like a fast-action scrolling game. Thanks
Your answer