Bullets in Godot-nodes solution+scripts?[3D]

SchusterSchuster Posts: 258Member
edited August 2016 in Programming
Hi, G:<br />I tried to reproduce the bullet from the 2d(space_shooter demo) and apply it in 3d but I don't know,it's probably not the best solution... does anyone have any solution? Thanks, I think this is another useful thing for newbies.<br /><br />script:<br />
<br />extends Area<br /><br /><br />const SPEED = 850<br /><br />var hit = false<br /><br /><br />func _process(delta):<br /><br /><br />#Bullet speed/vector3??<br />func _ready():<br />	set_process(true)<br /><br /><br />func _hit_something():<br />	if (hit):<br />		return<br />	hit = true<br />	set_process(false)<br />	get_node(&quot;anim_splash&quot;).play(&quot;splash&quot;)<br /><br /><br />func _on_visibility_exit_screen():<br />	queue_free()<br /><br /><br />#Hit an Enemy<br />func _on_bullet_area_enter( area ):<br />	if (area.has_method(&quot;injure&quot;)):<br />		area.destroy()<br />		_hit_something()<br /><br /><br />#Hit walls,etc.<br />func _on_bullet_body_enter( body ):<br />	_hit_something()
<br /><br />bullet_img_01png<br />bullet_img_02png<br /><br /><br /><br /><br />

Tags :


  • SchusterSchuster Posts: 258Member
    The solution above is not good and is useful for the rockets or grenades where are seen in flight.<br /> Lots of games uses the so-called Hitscan,(not suitable for perfect simulation of the behavior of projectiles),but are just what works in most games.<br />....and so, I put together this solution as it is in the images but I don't know if it would work this way because I have not yet written with someone's help :) scripts<br />, it is just an idea how it could be.<br /><br />a couple of interesting links on this thing:<br />https://en.wikipedia.org/wiki/Hitscan<br />https://www.quora.com/How-do-the-bullets-work-in-shooter-games<br />http://gamedev.stackexchange.com/questions/13650/how-are-bullets-simulated-in-video-games<br />images:<br />Hitscan_dia01.jpg<br />Hitscanbullet_img_03.png<br />wall_img_04.png<br />body_img_05.png<br /><br />P.S I think we should create a demo with this for newbies because that there absolutely is missing and it is the basis for the FPS
  • SchusterSchuster Posts: 258Member
    So the first part should work-adding "bullets" when fired :)...the blue ball(bullet) is only for illustrate.We want to shoot just hitscan-bullet so no object will be.<br />...needs implement LMB control for shooting and vector/speed "bullet"<br />bullet_spawner script: wip :)<br />
    extends Position3D<br /><br />var b = bullet02<br />export (PackedScene) var bullet02<br /><br />func _ready():<br />&nbsp; &nbsp; var b = preload(&quot;res://scenes/bullet02.scn&quot;).instance()<br />&nbsp; &nbsp; var b = bullet02.instance()<br />&nbsp; &nbsp; add_child(b)<br />&nbsp; &nbsp; set_process(true)
    <br /><br />bul_Test01.png<br />btest04.png<br />btest03.png<br />btest05.png<br /><br />
Sign In or Register to comment.