New answers tagged

1

You don't need to add the Guns via the inspector one by one. Just execute FindObjectsOfType at the start of your game: Gun[] guns; void Start () { guns = FindObjectsOfType<Gun> (); foreach (Gun gun in guns) { Debug.Log("Found " + gun.gameObject.name); //Now you can access their location with gun.gameObject.transform.position ...


2

To solve all of this problems you still have to write quite a lot of code. So this answer is just a general overview of what you need to do, not a complete implementation. When you need specific help with one of these points, feel free to ask it as a new question. When you want multiple goals, you need to change public Transform goal; into an array of ...


0

I do have some answers for you: how can I randomly move the robot asset through the house? Use a navmesh agent. (this tutorial will help you)The robot would have to set a new random target, once it reaches it's previous. This could be done by selecting a random one out of several predefined target points. Alternatively, you could attach a standart ...


3

It depends primarily on what the player is supposed to do. In games where a gun is facing in the walking direction and the main thing the player is supposed to do is to shoot things by accurately aiming the gun, it makes sense to point the camera and the gun in the same direction, so the player sees what they're shooting at. Disadvantages are that you ...


2

This is the signature of the function you're trying to use Vector3.Project(Vector3 vector, Vector3 onNormal) you're passing it only 1 parameter. And this is the first problem. The latter is that a Vector3 does not contain a Camera property.


0

From your code it is not clear if you use GameComponents or not, so I answer for both. I assume you do, since I think you are able to draw the Red Block and not update it. Which leads me to assume you haven't seen the Update and Draw methods in the main class. Behavior and player input is handled in the gameloop. The gameloop is basically the "update the ...


0

If by elastic, you mean as though it was attached by a rubber band: Whenever it passes the object, increase the force applied to it (with a maximum force of the remaining distance). To determine if it passes the object, you can check if the distance from the object increased since the previous frame. But be careful of performance issues. As a side note, ...


0

If I understand your question correctly, you want to smoothly move an object from point A to point B. I would use a coroutine: private IEnumerator Move_Routine(Transform transform, Vector3 from, Vector3 to) { float t = 0f; while(t < 1f) { t += Time.deltaTime; transform.position = Vector3.Lerp(from, to, Mathf.SmoothStep(0f, ...


0

well i fixed it. lol well the reason it wasn't working right was because i used translate on another part of the script to move the whole ship on a rail while this part moves side to side. so these few line of code weren't the problem at all. guess that's what i get for trying to be secretive and hiding code. MovePosition works fine with collision. but still ...


0

I'm a beginer in pygame and python so i'm having some troubles hahahahah. I figured ou what my problem was. Pygame does not reognize two keys being pressed or released at the same time. So for example, when i press the down button, and the right button the program states that self.down_is_down = True and self.right_is_down = True so the player gain a ...


0

My apologies if I'm wrong but.. Dude, drop that script and take a look at the tutorials, specially -Roll a Ball- and SpaceShooter You're not checking for collisions you just posted the same code twice. The code for move your object have not sense: You're not applying forces or transforms. You're just adding and subtracting your current position to that ...


0

Use floats for your logic & cast or round then to integers as you pass them to the drawing methods.


0

If you remove the part bellow, maybe it can work. I do this in the JavaScript game and worked, try it: if event.type == pygame.KEYUP: if event.key == pygame.K_LEFT: self.left_is_down = False if self.right_is_down: self.speed_x = self.velocity else: self.speed_x = 0 if event.key == pygame.K_RIGHT: ...


0

This question on partial path-finding presents one solution - modify your path finding algorithm to remember the node visited that had the closest estimated distance to the target. Eventually, the path-finding will fail to get a route to the target (since it was unreachable), but you will have a path to the closest point encountered while it searched.



Top 50 recent answers are included