Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 671795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:24:46+00:00 2026-05-14T00:24:46+00:00

What I am trying to create is a rocket that will hug the track

  • 0

What I am trying to create is a rocket that will hug the track in a straight direction.
ie) The rocket travels in a straight direction and can orientate based on its local x axis. This is so it can go up/down ramps and never hit the ground.

Currently I am using PhysX opengl and C++.

This is the method I’m trying right now:
1. Ray cast from ahead of the missile (ray casting downwards)
2. If the ray cast is less then the expected ray cast length, then I have to orientate up.
3. If the ray cast is more then the expected ray cast length, then I have to orientate down.

Now the problem, I am having is that my missile is orientating at an arbitary angle (I’m giving it 1 degrees.) Though I think this is a bad approach because the amount of frames in the game is not as much as I would think there would be. So the rocket would run into a ramp.

My main question is: is there a better way of approaching this and how?

NxVec3 frontRayLoc = m_rocketConfig->getValueForKey<NxVec3>("r_frontRayCastLocation");
float threshhold = m_rocketConfig->getValueForKey<float>("r_angleThreshhold");
float predRayCastHeight = m_rocketConfig->getValueForKey<float>("r_predRayCastHeight");

NxVec3 rayGlobalPos_1 = m_actor->getGlobalPosition() + m_actor->getGlobalOrientation() * frontRayLoc;
NxVec3 dir = m_actor->getGlobalOrientation() * NxVec3(0,-1.0,0);
NxReal dist1 = castRay(rayGlobalPos_1, dir);

// Get the percentage difference
float actualFrontHeight = abs(1 - (dist1/predRayCastHeight));

// See if the percentage difference is greater then threshold
// Also check if we are being shot off track
if ((actualFrontHeight > threshhold) && (dist1 != m_rayMaxDist)){
    // Dip Down
    if (dist1 > predRayCastHeight){
        printf("DOWN - Distance 1: %f\n", dist1);
        // Get axis of rotation
        NxVec3 newAxis = m_actor->getGlobalOrientation() * NxVec3(1.0,0,0.0);
        // Rotate based on that axis
        m_orientateAngle = -1.0 * m_orientateAngle; // For rotating clockwise
        NxQuat newOrientation(m_orientateAngle, newAxis);
        NxMat33 orientation(newOrientation);
        m_orientation = m_orientation * orientation;
        // Orientate the linear velocity to keep speed of rocket and direct away from road
        NxVec3 linVel = m_actor->getLinearVelocity();
        m_actor->setLinearVelocity(m_orientation * linVel);
    }
    // Go Up
    else if (dist1 < predRayCastHeight){
        printf("UP - Distance 1: %f\n", dist1);
        // Get axis of rotation
        NxVec3 newAxis = m_actor->getGlobalOrientation() * NxVec3(1.0,0,0.0);
        // Rotate around axis
        NxQuat newOrientation(m_orientateAngle, newAxis);
        m_actor->setGlobalOrientationQuat(newOrientation);
        NxMat33 orientation(newOrientation);
        m_orientation = m_orientation * orientation;
        // Orientate the linear velocity to keep speed of rocket and direct away from road
        NxVec3 linVel = m_actor->getLinearVelocity();
        m_actor->setLinearVelocity(m_orientation*linVel);
    }
        m_actor->setGlobalOrientation(m_orientation);
}

Thanks for the support 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:24:46+00:00Added an answer on May 14, 2026 at 12:24 am

    If your ray trace can determine the height of the terrain at some point out ahead, why couldn’t you just determine the height of the terrain at the current horizontal coordinates of the rocket, and render the rocket at a fixed height above that?

    I.e., you seem to be trying to invent a guidance system for the rocket, when it sounds like all you really need is to figure out where to draw it.

    Actually, you probably could get the orientation for the rocket by making it match the slope of the terrain underneath it, so that it doesn’t appear dead level all the time. It would look sort of strange if it were level while tracking over noticeable slopes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build a Chrome browser extension, that should enhance the way the
I am trying to redirect to a specific path based on HTTP_HOST or SERVER_NAME
I'm trying to build a C++ extension for python using swig. I've followed the
I'm trying to write test harness for part of my Android mapping application. I
I am trying to load a html page through UIWebview.I need to disable all
I am trying to understand the practical difference during the execution of a program
I am playing with TFS 2010, and am trying to setup a build process
I have several USB mass storage flash drives connected to a Ubuntu Linux computer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.