Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Unity DOTS help needed!

DoomPriestK

Active Coder
Is anyone here dealing with DOTS in Unity?

Anyone know why this is giving me : ItemMovementSystem.cs(34,63): error CS0103: The name 'floatSpeed' does not exist in the current context



[CODE lang="csharp" title="Data Orientated Technology Stack Code" highlight="34,"]// This Script Is A System To Deal With Item Movement on the TAG Script: Item Movement.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Entities;
using Unity.Jobs;
using Unity.Transforms;
using Unity.Mathematics;

public class ItemMovementSystem : JobComponentSystem
{

// This Is A Job System That Runs Every Frame
protected override JobHandle OnUpdate(JobHandle inputDeps)
{



// Get The Per-Frame Time ------> (Time.deltaTime was replaced with (float)Time.ElapsedTime)
var deltaTime = (float)Time.ElapsedTime;

// For Each Entity (Object) With The Specified Script
Entities.ForEach((ref Translation translation, ref Rotation rotation, in MovementData movementData) =>
{
// Do Rotation
rotation.Value = math.mul(rotation.Value, quaternion.RotateX(math.radians(movementData.spinOnX * deltaTime)));
rotation.Value = math.mul(rotation.Value, quaternion.RotateY(math.radians(movementData.spinOnY * deltaTime)));
rotation.Value = math.mul(rotation.Value, quaternion.RotateZ(math.radians(movementData.spinOnZ * deltaTime)));


// Do Floating
Vector3 currentFloatPosition = translation.Value;
float targetHeight = Mathf.Sin(Time.ElapsedTime * floatSpeed);
translation.Value.y = movementData.floatHeight * deltaTime;


// Run This On The Main CPU Thread
}).Run();

return default;
}




}[/CODE]


The Tag Script I use on Entities:

[CODE lang="csharp" title="Data Orientated Technology Stack Code" highlight="13,"]using UnityEngine;
using Unity.Entities;

[GenerateAuthoringComponent]
public struct MovementData : IComponentData
{
[Header("Spinning")]
public float spinOnX;
public float spinOnY;
public float spinOnZ;

[Header("Floating")]
public float floatSpeed;
public float floatHeight;
}[/CODE]
 
Last edited:

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom