Class TCastleStickToSurface

Unit

Declaration

type TCastleStickToSurface = class(TCastleBehavior)

Description

Behavior to make parent TCastleTransform stick to a surface of another TCastleTransform Target. The example use-case is to stick things to the surface of the terrain underneath.

Hierarchy

Overview

Methods

Protected function CanAttachToParent(const NewParent: TCastleTransform; out ReasonWhyCannot: String): Boolean; override;
Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); override;
Public function PropertySections(const PropertyName: String): TPropertySections; override;

Properties

Public property Direction: TVector3 read FDirection write FDirection;
Published property Target: TCastleTransform read FTarget write SetTarget;
Published property OnlyAtDesign: Boolean read FOnlyAtDesign write FOnlyAtDesign default true;
Published property DirectionPersistent: TCastleVector3Persistent read FDirectionPersistent ;

Description

Methods

Protected function CanAttachToParent(const NewParent: TCastleTransform; out ReasonWhyCannot: String): Boolean; override;

This item has no description. Showing description inherited from TCastleBehavior.CanAttachToParent.

Check can this behavior be added to NewParent. When this returns False, it has to set also ReasonWhyCannot. When overriding this, you can use e.g. this code to make sure we are the only behavior of given class:

function TCastleBillboard.CanAttachToParent(const NewParent: TCastleTransform;
  out ReasonWhyCannot: String): Boolean;
begin
  Result := inherited;
  if not Result then Exit;

  if NewParent.FindBehavior(TCastleBillboard) <> nil then
  begin
    ReasonWhyCannot := 'Only one TCastleBillboard behavior can be added to a given TCastleTransform';
    Result := false;
  end;
end;

Public constructor Create(AOwner: TComponent); override;

This item has no description.

Public destructor Destroy; override;

This item has no description.

Public procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); override;

This item has no description. Showing description inherited from TCastleBehavior.Update.

Continuously occuring event, for various tasks.

Public function PropertySections(const PropertyName: String): TPropertySections; override;

This item has no description. Showing description inherited from TCastleComponent.PropertySections.

Section where to show property in the editor.

Properties

Public property Direction: TVector3 read FDirection write FDirection;

Direction in which we check for collisions to stick the parent to Target. The default direction is -Y (that is, (0, 1, 0)) which makes the parent stick to the object under it, as if the gravity was forcing it down immediately.

Published property Target: TCastleTransform read FTarget write SetTarget;

Target to which Parent of this behavior sticks.

TODO: Rotating the target right now doesn't make proper behavior, test by rotating terrain in examples/terrain/.

Published property OnlyAtDesign: Boolean read FOnlyAtDesign write FOnlyAtDesign default true;

Perform stickiness only at design-time. This is True by default and makes this behavior trivially optimized at runtime.

Published property DirectionPersistent: TCastleVector3Persistent read FDirectionPersistent ;

Direction that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write Direction directly.

See also
Direction
Direction in which we check for collisions to stick the parent to Target.

Generated by PasDoc 0.16.0-snapshot.