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]
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: