GithubHelp home page GithubHelp logo

_speed at null about unitysteer HOT 4 CLOSED

ricardojmendez avatar ricardojmendez commented on August 23, 2024
_speed at null

from unitysteer.

Comments (4)

ricardojmendez avatar ricardojmendez commented on August 23, 2024

Which vehicle are you using - Autonomous or Biped? I expect autonomous, given your mention of _speed, but how can that value be null? It's a float, and value types cannot be null.

Please elaborate.

from unitysteer.

Doh-a avatar Doh-a commented on August 23, 2024

Sorry about the lack of precision.

Yes it's an autonomous Vehicle (it's for some kind of bugs, so I think this is the best in my case).

You are right _speed is not null, it's at NaN. I cannot explain why.

In the Velocity I put this lines :

Debug.Log("speed : " + _speed);
Debug.Log("forward : " + Transform.forward);
return Transform.forward * _speed;

And I get two kind of outputs.
One which is good :
speed : 0
forward : (0.0, 0.0, 1.0)

And one which is not :
speed : NaN
forward : (-0.2, -0.1, 1.0)

Which of course got a :

rigidbody.position assign attempt for 'walkingBug(Clone)' is not valid. Input position is { NaN, NaN, NaN }.
UnityEngine.Rigidbody:MovePosition(Vector3)
TickedVehicle:ApplySteeringForce(Single) (at Assets/AlterfaceProject/scripts/UnitySteer/Behaviors/TickedVehicle.cs:268)

I'm still looking for a good explanation about this. And in particular why some times I've got a speed at 0 and some time at NaN. Unfortunatly I didn't manage to find out.
I never change the speed by myself (anyway this is an internal value).

After some others tests.

If I changed the declaration, in order to init the value like that :

float _speed = 0.0f;

I got the same problem which make sens, this is the same thing than float _speed; (http://msdn.microsoft.com/en-us/library/83fhsxwc.aspx)

But if I change the init value to :

float _speed = 0.1f;

I got no error at all.

A final test to be really sure.
I changed a little bit the CalculatePositionDelta like this :

protected override Vector3 CalculatePositionDelta(float deltaTime)
    {
        if(System.Single.IsNaN(_speed))
            return new Vector3(0,0,0);
        else
            return Velocity * deltaTime;
    }

Of course I get no error, wich mean the trouble is really that _speed is at NaN. But this is like killing the messenger, it was just a test to be sure.

I'm probably missing a simple thing, but I'm not able to find what.

from unitysteer.

ricardojmendez avatar ricardojmendez commented on August 23, 2024

If you look at the AutonomousVehicle code, you'll see that the only place where _speed is set is on the Speed setter, and the only thing that does is a perform a clamp of the value passed with MaxSpeed. I suggest you add some Debug.LogError in the care of either being a NaN, along with a stacktrace, right about here:

https://github.com/ricardojmendez/UnitySteer/blob/development/Behaviors/AutonomousVehicle.cs#L22

from unitysteer.

ricardojmendez avatar ricardojmendez commented on August 23, 2024

Closing until we get more details.

from unitysteer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.