# Raycast from a particular point

How would I cast my slope ray from the tip of the ground ray and if I adjust my ground ray length the slope ray moves with it? They both are currently starting from the same point but the picture i drew shows what I’m wanting to do

``````using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public class GroundCheck : MonoBehaviour
{
PlayerController playerController;

[SerializeField] private float groundRayLength = 0.55f;
[SerializeField] private float slopeRayLength = 1.25f;
private void Awake()
{
playerController = GetComponent<PlayerController>();
}

private void FixedUpdate()
{
IsGrounded();
IsOnSlopeWithinLimit();
}
public bool IsGrounded()
{
float rayLength = playerController.characterController.height * 0.5f + groundRayLength;
Vector3 rayOrigin = transform.position + Vector3.up * (playerController.characterController.height * 0.5f);

return Physics.Raycast(rayOrigin, Vector3.down, rayLength, groundLayers);
}

public bool IsOnSlopeWithinLimit()
{
Vector3 rayOrigin = transform.position + Vector3.up * (playerController.characterController.height * 0.5f);
Ray slopeRay = new Ray(rayOrigin, Vector3.down);

return Physics.Raycast(slopeRay, out RaycastHit slopeHit, slopeRayLength, groundLayers) && Vector3.Angle(Vector3.up, slopeHit.normal) <= playerController.characterController.slopeLimit;
}
}

``````

You can use the raycasthit.distance to find the length of the ground ray. You can then take the total length and subtract that distance to find the length the second ray needs to be.