Click here to Skip to main content
15,891,947 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to have an object shoot shoot straight at a target where the target is a Transform. The bullet is set to look at and seek the transform, but the target transform is at the feet of the other object that its shooting at so that it can spawn in the correct orientation.

So the bullet is seeking the feet and I want to somehow offset the Transform of the target and still have the Transform GameObject at the feet of the Player.

Here's the code:
C#
target = nearestEnemy.transform;


where target is the object hes shooting at and the nearestEnemy.transform is where the bullet is shooting towards (feet).

What I have tried:

I wanted to try and add an offset to the nearestEnemy.transform on the y by the firePoint transform y:

C#
target = nearestEnemy.transform + firePoint.transform.y;


But you can't use the '+' symbol with Transforms.
Posted
Updated 19-Feb-17 14:51pm
Comments
Patrice T 19-Feb-17 21:22pm    
"But you can't use the '+' symbol with Transforms."
Do you understand that we have no idea what this code is doing.
Asking questions is a skill[^]
Member 13006389 19-Feb-17 21:42pm    
object1 is shooting at object2's transform, but his transform is at the bottem of object2. How can I change where object1 shoots by maybe adding an offset in the y direction to the transform so that the bullet goes more up?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900