mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-05 22:09:56 +03:00
Merge branch 'master' into 3.2
This commit is contained in:
@@ -55,6 +55,7 @@ efficient for millions of objects, but for a few thousands, GDScript should be f
|
||||
|
||||
extends MultiMeshInstance
|
||||
|
||||
|
||||
func _ready():
|
||||
# Create the multimesh.
|
||||
multimesh = MultiMesh.new()
|
||||
@@ -66,6 +67,7 @@ efficient for millions of objects, but for a few thousands, GDScript should be f
|
||||
multimesh.instance_count = 10000
|
||||
# Maybe not all of them should be visible at first.
|
||||
multimesh.visible_instance_count = 1000
|
||||
|
||||
# Set the transform of the instances.
|
||||
for i in multimesh.visible_instance_count:
|
||||
multimesh.set_instance_transform(i, Transform(Basis(), Vector3(i * 20, 0, 0)))
|
||||
@@ -74,24 +76,25 @@ efficient for millions of objects, but for a few thousands, GDScript should be f
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public class MultiMeshInstance : Godot.MultiMeshInstance
|
||||
public class YourClassName : MultiMeshInstance
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
// Create the multimesh.
|
||||
var multimesh = new MultiMesh();
|
||||
Multimesh = new MultiMesh();
|
||||
// Set the format first.
|
||||
multimesh.TransformFormat = MultiMesh.TransformFormatEnum.Transform3d;
|
||||
multimesh.ColorFormat = MultiMesh.ColorFormatEnum.None;
|
||||
multimesh.CustomDataFormat = MultiMesh.CustomDataFormatEnum.None;
|
||||
Multimesh.TransformFormat = MultiMesh.TransformFormatEnum.Transform3d;
|
||||
Multimesh.ColorFormat = MultiMesh.ColorFormatEnum.None;
|
||||
Multimesh.CustomDataFormat = MultiMesh.CustomDataFormatEnum.None;
|
||||
// Then resize (otherwise, changing the format is not allowed)
|
||||
multimesh.InstanceCount = 1000;
|
||||
Multimesh.InstanceCount = 1000;
|
||||
// Maybe not all of them should be visible at first.
|
||||
multimesh.VisibleInstanceCount = 1000;
|
||||
Multimesh.VisibleInstanceCount = 1000;
|
||||
|
||||
// Set the transform of the instances.
|
||||
for (int i = 0; i < multimesh.VisibleInstanceCount; i++)
|
||||
for (int i = 0; i < Multimesh.VisibleInstanceCount; i++)
|
||||
{
|
||||
multimesh.SetInstanceTransform(i, new Transform(Basis.Identity, new Vector3(i * 20, 0, 0)));
|
||||
Multimesh.SetInstanceTransform(i, new Transform(Basis.Identity, new Vector3(i * 20, 0, 0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,9 +91,11 @@ This is a simple example of how to create a sprite from code and move it using t
|
||||
|
||||
extends Node2D
|
||||
|
||||
# VisualServer expects references to be kept around
|
||||
|
||||
# VisualServer expects references to be kept around.
|
||||
var sprite
|
||||
|
||||
|
||||
func _ready():
|
||||
# Create a canvas item, child of this node.
|
||||
var ci_rid = VisualServer.canvas_item_create()
|
||||
@@ -130,9 +132,11 @@ The 3D APIs are different from the 2D ones, so the instantiation API must be use
|
||||
|
||||
extends Spatial
|
||||
|
||||
# VisualServer expects references to be kept around
|
||||
|
||||
# VisualServer expects references to be kept around.
|
||||
var mesh
|
||||
|
||||
|
||||
func _ready():
|
||||
# Create a visual instance (for 3D).
|
||||
var instance = VisualServer.instance_create()
|
||||
@@ -157,14 +161,16 @@ and moves a :ref:`CanvasItem <class_CanvasItem>` when the body moves.
|
||||
.. tabs::
|
||||
.. code-tab:: gdscript GDScript
|
||||
|
||||
# Physics2DServer expects references to be kept around
|
||||
# Physics2DServer expects references to be kept around.
|
||||
var body
|
||||
var shape
|
||||
|
||||
|
||||
func _body_moved(state, index):
|
||||
# Created your own canvas item, use it here.
|
||||
VisualServer.canvas_item_set_transform(canvas_item, state.transform)
|
||||
|
||||
|
||||
func _ready():
|
||||
# Create the body.
|
||||
body = Physics2DServer.body_create()
|
||||
|
||||
Reference in New Issue
Block a user