c # – UNITY – Shoot the projectile in the direction of the weapon

I have a weapon spawning a projectile rebounding from collidors (a ricochet). It should shoot in the direction the weapon is aimed, but what I get is that the projectile always shoots 45 degrees to the right. I know that's because of my constantly declared vector 2.

I've tried using Vector2.up, but it prevents the projectile from performing the rebound effect, as it always wants to go up.

How should I implement these things? I just want the projectile to shoot in the direction my weapon is aimed and bounce off colliders. By the way, this is a 2D game. I've attached my codes below so you can see. Thank you so much!

Projectile magazine:

private Rigidbody2D rb;
public static bool canMove = true;

void Start()
{
 rb = GetComponent();
 rb.velocity = new Vector2(10f, 10f);
}
void Update()
{
 //transform.Translate(Vector2.up * speed * Time.deltaTime);
 if (canMove)
 {
     rb.isKinematic = false;

 }
 else if (!canMove)
 {
     rb.isKinematic = true;
 }
} 

Weapons font:

float offset = -90f;

public GameObject projectile;
public Transform shotPoint;
public GameObject child;

void Start()
{

}

void Update()
{
    Vector3 diff = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
    float rotZ = Mathf.Atan2(diff.y, diff.x) * Mathf.Rad2Deg;
    transform.rotation = Quaternion.Euler(0f, 0f, rotZ + offset);

    if (Input.GetMouseButtonDown(0))
    {
        Instantiate(projectile, shotPoint.position, transform.rotation);
        Projectile.canMove = true;
    }
}

kotlin – Use GOOGLE MAPS to find out if one coordinate is ahead of another with a defined direction / direction

I'm developing an app to get time estimates based on a set of points (lat, lng). The estimates are based on a given trajectory (defined polyline).
Can I know when one point is earlier than another?
In other words, I know if the coordinate A (22.1305, -104.12541) lies before the coordinate B (22.1069, -102.3657).

** Visually, it's easy, as shown below, in the order that interests me, that the A stands in front of the B
Enter image description here

I hope you can help me!
Development in Kotlin with Google Maps

unity – Should a `Vector2.Rotate (float angle)` method in a universe turn clockwise in a counterclockwise direction?

I'm doing a 2D game in Unity and from what I understand The convention is that an angle of 0 is up and by increasing the angle, the object is rotated counterclockwise,

By the way, I have made this assumption by myself the rotation.z Value in the inspector window of a transformation. If it is 0, the object is transform.up points towards positive y. Increasingly rotation.z turns the object counterclockwise, d. H. the object transform.up Point to a negative X at 90 degrees. Let me know if this is wrong.

Given the convention where increasing the angle counter-clockwise, what should be my extension method Vector2.Rotate(this Vector2 vector, float angle) do? My question is if that works Vector2.up.Rotate(90) would result in a clockwise or counterclockwise rotation, where would be clockwise Vector2.right and counterclockwise would give Vector2.left,

At first it seemed to me an initiative that this would be the case obviously rotate clockwise. It's a positive number, so it turns clockwise. I am not sure where this bias comes from, but with Rotate(90) feels like it should turn right (clockwise).

After thinking about it, I think it makes more sense to do so Rotate(90) turn counterclockwise. Since the universe assumes a higher / positive angle that results in a counterclockwise rotation, the method must also adhere to this rule. But for some reason, it does not seem intuitive to me that I would need to call rotates with a negative number to spin clockwise. Rotate(-90) // clockwise,

Feedback, anecdotes, ideas or conventions highly appreciated, thanks!

Directed Trees: Determine all edges and vertices in a particular direction

I am an electrical engineer with no experience in graph theory. However, I have a problem that, in my opinion, can be solved by graph theory. We have a directional tree, like the following. We want to find all the vertices and edges that emanate from a vertex in a particular direction. For example, in the following illustration we want to identify the vertices and edges from vertex 1 (the red lines). Is there an algorithm for this (preferably in MATLAB)? The edges are the same weight.

Enter image description here

Javascript – How can I get my character to shoot in the direction he looks?

I'm trying to make a game in which there's a wave of enemies on a character, and I try to make my character as I go up and hit the kill button, the character shooting the balls, and the same for each other direction.
Right now it's the only real shooting.

                // This is the hero object
Function Hero () {
this.sprite = sprite;
this.x = 0;
this.y = canvas.height / 2;
this.imgWidth = 128;
this.imgHeight = 192;
this.frameWidth = this.imgWidth / 4;
this.frameHeight = this.imgHeight / 4;
this.dx = 4;
this.dy = -4;
this.health = 100;
this.directionMode = 2;
this.currentFrame = 0;
this.updateFrame = function () {
this.currentFrame + = 0.2;
}
this.showHealth = function () {
ctx.fillStyle = "green";
ctx.fillRect (this.x, this.y-10, (this.health/100) * 50.5);
ctx.strokeRect (this.x, this.y-10, (100/100) * 50, 5);
}
this.show = function () {
if (downPressed! = true && upPressed! = true && leftPressed! = true && rightPressed! = true) {
this.directionMode = 0;
this.currentFrame = 0;
}
this.updateFrame ();
this.walkingMode = Math.floor (this.currentFrame)% 4;
ctx.drawImage (this.sprite, this.walkingMode * this.frameWidth, this.directionMode * this.frameHeight, this.frameWidth, this.frameHeight, this.x, this.y, this.frameWidth, this.frameHeight);
}
this.update = function () {
if (rightPressed && this.x < canvas.width - this.imgWidth/4){
            this.x = this.x + this.dx;
        }
    if (leftPressed && this.x > 0) {
this.x = this.x - this.dx;
}
if (upPressed && this.y> 0) {
this.y = this.y + this.dy;
}
if (downPressed && this.y < canvas.height - this.imgHeight/4){
            this.y = this.y - this.dy;
        }
    }
}


//this is the bullet object
    function Bullet(x, y){
    this.x = x;
    this.y = y;
    this.toDelete = false;
    this.show = function(){
        ctx.beginPath();
        ctx.arc(this.x, this.y, 7, 2, Math.PI*2);
        ctx.fillStyle = "grey";
        ctx.fill();
        ctx.closePath();
    }
    this.move = function(){
        this.x = this.x + 5;
    }
    this.deletion = function(){
        this.toDelete = true;
    }
}

//this is the game loop
function draw() {
        bullets = bullets.filter((bullet) => bullet.x <= viewLimit);
        enemies = enemies.filter((enemy) => enemy.x> = viewLimit1);
while (enemies.length <= enemiesPerTick && kills <= 5) {
var enemy = new Enemy (canvas.width, random (0, canvas.height - 60));
enemies.push (enemy);
}
for (var v = 0; v <enemies.length; v ++) {
enemies[v]showhealth ();
}
ctx.clearRect (0, 0, canvas.width, canvas.height);
hero.show ();
hero.update ();
hero.showHealth ();
for (var i = 0; i <bullets.length; i ++) {
roll[i].Show();
roll[i].Move();
}
for (var j = 0; j <enemies.length; j ++) {
enemies[j].Show();
enemies[j].Move();
}
for (var t = 0; t < enemies.length; t++) {
                enemies
            }
            collision();
            drawScore();
            if (enemies.length == 0 && boss1.health > 0) {
boss1.show ();
boss1.move ();
boss1.showHealth ();
}

requestAnimationFrame (draw);
}
console.log (enemies, bullets);
to draw();


// here are the keyEvents
var cPressed = false;
var rightPressed = false;
var leftPressed = false;
var upPressed = false;
var downPressed = false;
Function keyDownHandler (e) {
if (e.key == "ArrowRight") {
rightPressed = true;
hero.directionMode = 2;
}
otherwise if (e.key == "ArrowLeft") {
leftPressed = true;
hero.directionMode = 1;
}
if (e.key == "ArrowUp") {
upPressed = true;
hero.directionMode = 3;
}
otherwise if (e.key == "ArrowDown") {
downPressed = true;
hero.directionMode = 0;
}
otherwise if (e.key == "c") {
var bullet = new Bullet (hero.x + 25, hero.y + 15);
bullets.push (bullet);
hero.directionMode = 2;
}
}
function keyUpHandler (s) {
if (e.key == "ArrowRight") {
rightPressed = false;
}
otherwise if (e.key == "ArrowLeft") {
leftPressed = false;
}
if (e.key == "ArrowUp") {
upPressed = false;
}
otherwise if (e.key == "ArrowDown") {
downPressed = false;
}
otherwise if (e.key == "c") {
cPressed = false;
}
}

I would be glad if you could help me, because I held myself in a few days and can not find an answer.

Geometry – How do you know if two faces point in the same direction?

In my code I create a mesh that consists of several tiles. These tiles can have edges that are split, and I need to know if the normals of the tiles that have common edges have the same direction, because I calculate the edges' normals to smooth the light. Before I used Vector.Dot () I sometimes have two tiles with a curve that makes it impossible to use this feature, as you can see in the 4th image.
and the only information I have in the bill is the 2 normal of the tile.

Enter image description here Picture 1: different direction
other direction Picture 2: different direction
Same direction Picture 3: same direction
Same direction Picture 4: same direction

Same direction Picture 5: same direction

Unit – How to use the mouse to exert force in direction and / or touch input direction and input speed?

I have to object. I can move object 1 (my player) with the mouse (or touch for smartphone version).

I want to exert a force on object 2 when object 1 hits it. The force direction must be the mouse vector direction or the touch vector direction.

For mouse input, I use the event OnMouseDown and OnMouseDrag to determine the original position of the mouse.

But I think that's not the best approach. Behavior is not what I expect

void OnMouseDown ()
{

mouseDragStartPosition = Input.mousePosition;

// Convert the position of the cubes from the world to Screen Point
screenSpace = Camera.main.WorldToScreenPoint (transform.position);

// Compute the difference between the cube's world position and the mouse's screen position, which has been converted to a world point
offset = transform.position - Camera.main.ScreenToWorldPoint (new Vector3 (Input.mousePosition.x, Input.mousePosition.y, screenSpace.z));

}


void OnMouseDrag ()
{


// track the mouse position
var curScreenSpace = new Vector3 (Input.mousePosition.x, Input.mousePosition.y, screenSpace.z);

// convert the mouse position of the screen to a world point and adjust it with offset
var curPosition = Camera.main.ScreenToWorldPoint (curScreenSpace) + offset;


transform.position = new Vector3 (curPosition.x, ClampY, curPosition.z);
}

void OnCollisionEnter (collision collision)
{
Debug.Log ("OnCollisionEnter");
if (collision.collider.tag == "Disc")
{
ApplyForce ();
}

}



void ApplyForce ()
{
Vector3 direction = mouseDragStartPosition - Input.mousePosition;
direction = new Vector3 (direction.x, ClampY, direction.z); // used ClampY to disallow + -Y
DiscRb.AddForce (direction * 1, ForceMode.Impulse);
}

Enter image description here

numerics – Calculates the distance between two points and determines the direction

I program a molecular dynamic program with periodic boundary conditions. Here I have a problem:

I have a list of coordinates like

list = RandomReal[{0, 1}, {5, 2}]

And now I want to have the distances.

I'm doing that

EuclideanDistance @@@ subsets[list, {2}]

But now I do not know the direction, so if the distance was not positive or negative to the square.
Does anyone know how to get the sign?
Because I need that for calculating my periodic boundary conditions

Google Backup and Sync – just one direction?

I'm using "Google Backup and Sync" to sync a directory on my local computer to my Google Drive store. After this The synchronization for that is complete first Time,

1) I have deleted some of the content in my browser local Directory (content already synced to Google Drive).
2) Then I added some new content to mine local Directory.
3) After that, I ran Sync again (to sync new content to Google Drive).
However, not only was the new content uploaded to my Google Drive, it also found that some of the content in my local directory was missing, and an attempt was made to download the missing content from Google Drive.
I have two questions:

1) Is there a way to reach my destination without downloading the missing content to my local computer? (ie: just sync in one direction)?
2) I need to make sure the synced content in Google Drive does not match my local directory deleted, Is it possible?