Customise Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorised as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.

No cookies to display.

[ad_1]

I’ve a process which i’ve a transferring ship that may shoot in any course i need. i’ve to shoot to standing or transferring close by objects.

the issue is, I can not appropriately calculate true shoot course.I need to discover a course after ship velocity apply on it then bullet go to focus on place.

Ship shoot methodology :

public void shoot(vector3 course)
{
   var projectile=  new Projectile();
   projectile.Velocity = Ship.LinearVelocity + Vector3.Normalize(course) * Ship.GunInfo.ProjectileSpeed;
   projectile.Place = Ship.Place;
   World.Add(projectile);
}

Projectile replace methodology :

public void Replace(TimeSpan deltaTime)
{
    Place+= Velocity * deltaTime;
}

So what’s true course which should to be handed into shoot methodology?

I attempted bellow calculations :

1- first answer i attempted to shoot targets : (actually unhealthy accuracy)

var baseDirection = goal.Place - Ship.Place;
var course = baseDirection - Ship.LinearVelocity/Ship.GunInfo.ProjectileSpeed;
shoot(course);

2- second answer i attempted to shoot targets : (higher accuracy)

var baseDirection = goal.Place - Ship.Place;     
var shootDirection = Ship.LinearVelocity + Vector3.Normalize(baseDirection) * Ship.GunInfo.ProjectileSpeed;
var course = Vector3.Replicate(- shootDirection, Vector3.Normalize(baseDirection))
shoot(course);
  • All velocities (ship, projectile) are vector3.

  • I do not use any physic engine however i’ve vector3 math capabilities like (normalize, undertaking, dot, …).

  • Normalize imply vectorA/size(vectorA) meaning vector with size one

  • ship pace at shoot time is fixed however periodically change velocity and course.

  • there is no such thing as a gravity,wind and so on all velocity stay fixed besides ship that change its method.

my solutions

[ad_2]

Leave a Reply

Your email address will not be published. Required fields are marked *