SleepingTroll Posted April 2, 2012 Posted April 2, 2012 (edited) Velocity[a] is a Vector3 type (all doubles), Proximity is a double as is Influence. The highlighted code produces a cannot convert double to float error... I have tried (double)0 and that did not solve the problem. Any ideas? Velocity[a] = (new Vector3( [color="Red"]Proximity.X != 0[/color] ? Velocity[a].X + (1/(Influence * Proximity.X)) : Velocity[a].X, [color="Red"]Proximity.Y != 0[/color] ? Velocity[a].Y + (1/(Influence * Proximity.Y)) : Velocity[a].Y, [color="Red"]Proximity.Z != 0[/color] ? Velocity[a].Z + (1/(Influence * Proximity.Z)) : Velocity[a].Z )); Edited April 2, 2012 by snarfblam Quote
Leaders snarfblam Posted April 2, 2012 Leaders Posted April 2, 2012 You're code is a bit hard to read. While that might sound nit-picky, and it's a subjective thing, when code is more readable, it is easier to understand and reason about it, especially at a glance. It also helps us help you. The documentation for Vector3 states that the fields are floats, not doubles. You either need to cast to float, or make sure that all of your variables are floats rather than doubles. Something like this should work. Velocity[a] = (new Vector3( Proximity.X != 0 ? [color="Blue"](float)([/color]Velocity[a].X + (1/(Influence * Proximity.X))[color="Blue"])[/color] : Velocity[a].X, Proximity.Y != 0 ? [color="Blue"](float)([/color]Velocity[a].Y + (1/(Influence * Proximity.Y))[color="Blue"])[/color] : Velocity[a].Y, Proximity.Z != 0 ? [color="Blue"](float)([/color]Velocity[a].Z + (1/(Influence * Proximity.Z))[color="Blue"])[/color] : Velocity[a].Z )); Quote [sIGPIC]e[/sIGPIC]
SleepingTroll Posted April 3, 2012 Author Posted April 3, 2012 I had assumed that a Vector3 type used double values... bad assumption! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.