Skip to content

Incorrect C# sample in Instancing_with_signals/shooting-example #7650

@JamesDepret

Description

@JamesDepret

Your Godot version: 4.1.stable

Issue description: Incorrect C# code sample:

URL to the documentation page: https://docs.godotengine.org/en/stable/tutorials/scripting/instancing_with_signals.html#shooting-example

We use the OnPlayerShoot() function in the last function reference. This throws two errors:

  • bulletInstance.Rotation = direction: direction is a Vector2, Rotation expects a float.
  • bulletInstance.Velocity: In the previous code sample we setup bullet, but made Velocity a private member, making it inaccessible
  • Setting Velocity to public in the bullet class gives the same issue as the first issue: bulletInstance.Velocity.Rotated(direction) => the Rotated method expects a float.

Potential solution (I'm not sure if this is correct)

  • Make Velocity a public field in the bullet class
  • change the Rotation line to
    bulletInstance.Rotation = direction.Angle();
  • change the Velocity.Rotated line to
    bulletInstance.Velocity = bulletInstance.Velocity.Rotated(direction.Angle());

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:manualIssues and PRs related to the Manual/Tutorials section of the documentationbugtopic:dotnet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions