I'm trying to move code from unity 3d to stride 3d but I have huge issues as IDE doesn't help me find words when I type as unity 3d does
the unity 3d code that works:
public Transform Planet; // to rotate to
void Update(){
PlanetDirection = Planet.position - transform.position;
planetDistance = MathFunctions.V3Distance(transform.position, Planet.position);
Ray ray = new Ray(transform.position, PlanetDirection);
RaycastHit hit;
if (Planet.GetComponent<Collider>().Raycast(ray, out hit, planetDistance) ){
transform.rotation = Quaternion.LookRotation( Vector3.Cross(transform.right, hit.normal) , hit.normal);
}
}
this is updated stride code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Stride.Core.Mathematics;
using Stride.Input;
using Stride.Engine;
using Stride.Physics;
namespace example1{
public class PlanetaryMovement : SyncScript{
public Colliders PlanetCollider;
public Entity Planet; // to rotate to
//maybe I don't need so much only Simulation
Stride.Physics.Simulation sim;
Vector3 near = this.Entity.TransformComponent.position;
Vector3 to = Planet.TransformComponent.position;
//var result = sim.Raycast(vectorNear.XYZ(), vectorFar.XYZ());
IList<HitResult> hit = new IList<HitResult>();
CollisionFilterGroups filterGroup = CollisionFilterGroups.DefaultFilter;
public override void Start(){
}
public override void Update(){
sim.RaycastPenetrating(near, to, hit, filterGroup);
PhysicsComponent col;
for(int i=0; i< hit.Count; i++){
if (PlanetCollider == hit[i].Collider){
this.Entity.Quaternion.Rotate(hit[i].Normal);
}
}
}
}
}
and the reference with witch I was trying to figure out how to translate my code
EDIT: -Updated the code errors that still exists:
[C:\programming\Stride 3D\example1\example1\Movement.cs(14,12)]: Error: The type or namespace name 'Colliders' could not be found (are you missing a using directive or an assembly reference?)
what I need is to link the HitResult with Planet somehow I don't know what to use to compare them.
Raycasting Simulation Simulation HitResult Physics quaternion